我有 2 个表格,我应该在其中显示数量,库存物品的数量和余额数量我写了如下查询:
SELECT I.Date as Date,
P.ResourceName as ItemName,
P.ResourceRate as Rate,
i.TotalInQty as InwardsQuantity,
s.TotalOutQty as OutwardsQuantity,
i.TotalInQty-S.TotalOutQty as Balance,
O.UnitSymbol As ItemUnit
FROM UnitMaster O
INNER JOIN Resource_Master P
ON O.UnitCode = P.Unitcode
LEFT JOIN
(
select sum(i.Qty) TotalInQty, Nameofitem
from Inwards_Master I
group by Nameofitem
) I
ON I.Nameofitem= P.ResourceName
LEFT JOIN
(
select sum(s.qty) TotalOutQty, Nameofitem
from Outwards_Master S
group by s.Nameofitem
) S
ON I.Date=S.Date
AND I.Nameofitem =S.Nameofitem
WHERE P.TenderCode=1
上面的查询给了我一个如下错误:
消息 8120,级别 16,状态 1,第 14 行列“Inwards_Master.Date”在选择列表中无效,因为它不包含在聚合函数或 GROUP BY 子句中。
任何人都可以帮我吗