错误子查询使用来自外部查询的未分组列“i.colorid”

时间:2018-04-17 15:12:41

标签: sql postgresql

以下是查询

select (select description from Colors where ID = I.ColorID) AS Color,
O.Sono,
O.Customer,
SUM(L.Quantity) AS Quantity, 
O.shipdate,I.VapID,L.OrderID 
from Orderlines  L, Items I, Orders O 
where L.Item = I.SKU AND I.PanelID=3 
AND O.ID=L.OrderID 
AND O.OrderType = 'Sales Order' 
 AND (L.Status < 1 OR L.Status is Null) 
Order by Color, shipdate

此查询出错 “子查询使用来自外部查询”

的未分组列“i.colorid”

1 个答案:

答案 0 :(得分:0)

select  description  AS Color,
O.Sono,O.Customer,SUM(L.Quantity) AS Quantity, O.shipdate,I.VapID,L.OrderID 
from Orderlines  L, Items I, Orders O, colors c  
where L.Item = I.SKU AND I.PanelID=3 AND O.ID=L.OrderID AND O.OrderType = 'Sales Order' 
and  c.ID = I.ColorID
AND (L.Status < 1 OR L.Status is Null) 
group by description,
O.Sono,O.Customer, O.shipdate,I.VapID,L.OrderID
Order by Color, shipdate