选择列表中的“ ProjectShipping.id”列无效,因为它既不包含在聚合函数中也不在GROUP BY子句中

时间:2019-06-28 20:07:08

标签: sql-server

我想总结从这里开始的工作:

I get wrong result when calculating weight

看起来像这样

enter image description here

所以我运行此查询

SELECT 
    ProjInfo.ProjectN AS BS,
    (SELECT SUM(ProjectShipping.[Weight] * DailyPaintProduction.[Quantity] )
     FROM DailyPaintProduction
     INNER JOIN ProjectShipping ON ProjectShipping.id = DailyPaintProduction.FK_idPartShip 
     INNER JOIN ProjectInfo ON ProjectInfo.id = ProjectShipping.IdProject
     WHERE DailyPaintProduction.FK_idPartShip = ProjShipp.id 
       AND FK_idNextProcess = 13 
       AND ProjectInfo.FK_Status != 'VENDRE DES MATIERES PREMIERES') AS 'weight fab',
    SUM(ProjShipp.[Weight]*ShippingNavisionQty) AS 'weight Shipp'
FROM
    ProjectShipping ProjShipp
INNER JOIN
    ProjectInfo ProjInfo ON ProjInfo.id = ProjShipp.IdProject
WHERE 
    ProjInfo.ProjectN = 'BS-00799'
GROUP BY 
    ProjInfo.ProjectN,
    --ProjShipp.id,
    ProjShipp.[Weight]
ORDER BY
    ProjInfo.ProjectN

但是我得到这个错误

  

消息8120,第16级,状态1,第11行
  选择列表中的“ ProjectShipping.id”列无效,因为它既不包含在聚合函数中也不在GROUP BY子句中。

如果我将ProjShipp.id添加到GROUP BY的问题得以解决,但是我没有得到摘要查询

请帮忙吗?预先感谢。

0 个答案:

没有答案