SQL组视图查询并与其他表连接

时间:2016-09-24 07:36:17

标签: sql

if

当我尝试获取Items.Iteminfo时,会发生错误。任何人都可以帮助我错了..

1 个答案:

答案 0 :(得分:0)

您必须将SELECT列表中的列包含在GROUP BY子句中。

    Select PurchasesBody.ItemId, 
       Items.Iteminfo, Sum(TTLQtyLose) As PurQty, 
       Avg(PerUnitCost) AS AvgRate, Sum(TTLValue) AS NetValue 
     From PurchasesBody 
       left Join Items On PurchasesBody.ItemId=Items.ItemId 
     Group By PurchasesBody.ItemId,Items.Iteminfo