select s.dateofentry, s.receiptno, cm.name as mfg, s.productid, p.name as product, s.quantity as manufacturedQty, inf.quantity as availableQty, f.rawmaterialid, rm.name as rawmaterial, (f.quantity * s.quantity) as usedQuantity, ir.supplierid, ir.rawmaterialid as inventory_rawmaterialID, SUM(ir.quantity) as inventory_rawmaterialQty from finishproductprofile f inner join sendtocompanyfromcontractmfg s on f.productid = s.productid inner join inventory_finishedproduct inf on inf.productid = f.productid inner join raw_material rm on f.rawmaterialid = rm.rawmaterialid inner join product p on f.productid = p.productid inner join inventory_rawmaterial ir on f.rawmaterialid = ir.rawmaterialid inner join contract_manufacturer cm on s.contractmfgid = cm.contractmfgid where s.isdelete = 0 group by s.receiptno, s.productid, ir.rawmaterialid order by dateofentry, productid, rawmaterialid;Now I want to add another data column to this query, so I get SUM of rejectedQty of rawmaterial but for some reason I am not getting the correct amount.
select rm.rawmaterialid, rm.name, SUM(iwr.quantity) from inventory_waste_rawmaterial iwr inner join raw_material rm on iwr.rawmaterialid = rm.rawmaterialid where iwr.isdelete = 0 group by rm.rawmaterialid order by rm.name
select s.dateofentry, s.receiptno, s.productid, inf.productid as pid, p.name as product, s.quantity as manufacturedQty, inf.quantity as availableQty, f.rawmaterialid, rm.name as rawmaterial, (f.quantity * s.quantity) as usedQuantity, ir.supplierid, ir.rawmaterialid as inventory_rawmaterialID, ir.quantity as inventory_rawmaterialQty, invwaste.quantity as wasteQty from finishproductprofile f inner join sendtocompanyfromcontractmfg s on f.productid = s.productid inner join inventory_finishedproduct inf on inf.productid = f.productid inner join raw_material rm on f.rawmaterialid = rm.rawmaterialid inner join product p on f.productid = p.productid inner join inventory_rawmaterial ir on f.rawmaterialid = ir.rawmaterialid inner join contract_manufacturer cm on s.contractmfgid = cm.contractmfgid inner join inventory_waste_rawmaterial invwaste on invwaste.rawmaterialid = rm.rawmaterialid where s.isdelete = 0 order by s.dateofentry, s.productid, f.rawmaterialid;
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
This award recognizes a member of Experts Exchange who has made outstanding contributions to the community within their first year as an expert. The Rookie of the Year is awarded to a new expert who has the highest number of quality contributions.