select
tblproduct.itemname As Item_Name,
((sum(tblpurchase.[case]) * tblproduct.pc)-
((sum(tblsale.[case]) * tblproduct.pc)+(sum(tblsale.nos))))
As Remaining_Stock
From
(tblproduct
left Join
tblpurchase on tblproduct.itemname=tblpurchase.itemname)
left join
tblsale on tblproduct.itemname = tblsale.itemname
where
tblproduct.itemname='Combo Soap'
group by
tblproduct.itemname
屏幕截图中显示错误。我无法运行此查询。请帮助我找到如何解决并运行此查询的解决方案!谢谢你。
感谢所有帮助我前进的人,让我能够解决这个问题。
SELECT tblproduct.itemname, Sum(tblpurchase_grouped.total_case) * Sum(tblproduct.pc) + Sum(tblpurchase_grouped.total_nos)) - (Sum(tblsale_grouped.total_case) * Sum(tblproduct.pc)+Sum(tblsale_grouped.total_nos)) AS Total FROM (tblproduct LEFT JOIN (SELECT itemname, SUM(nos) AS total_nos, SUM([case]) AS total_case FROM tblsale GROUP BY itemname ) AS tblsale_grouped ON tblproduct.itemname = tblsale_grouped.itemname) LEFT JOIN (SELECT itemname, SUM(nos) AS total_nos, SUM([case]) AS total_case FROM tblpurchase GROUP BY itemname ) AS tblpurchase_grouped ON tblproduct.itemname = tblpurchase_grouped.itemname WHERE tblproduct.itemname='Maza' GROUP BY tblproduct.itemname