我认为问题是我加入某处 我的OrderID不在一起
我不知道如何解决
T2.SetDiagonalValue val
T1.Range.AdvancedFilter xlFilterInPlace, T2.Range
Kinda喜欢被淘汰。 231未加入
select l.orderid, sum(l.qty) as units_sold, sum (l.qty) * p.price as Sales_Amount
from order_lines l join
products p
on p.prodid = l.prodid
group by l.orderid, p.price
Order by sum(l.qty) * p.price
答案 0 :(得分:1)
我怀疑您确实想要:
select l.orderid, sum(l.qty) as units_sold, sum(l.qty * p.price) as Sales_Amount
from order_lines l join
products p
on p.prodid = l.prodid
group by l.orderid
Order by Sales_Amount ;
group by
子句指定您要如何定义结果集中的行。如果每个orderid
只需要一行,那么orderid
中应该只有group by
。