表:订购产品
orderid quantity weight
-----------------------------------
4 5 0.1
4 2 0.5
5 3 2.5
5 7 0.9
1) 使用以下 SQL 命令,可以正确计算总重量,但忽略产品数量。如何扩展我的 SQL 命令来查询产品数量?
select orderid, sum (weight) as totalweight from orderproducts group by orderid
现在我有 ORDERID 4 的值(总重量)=> 0.6
必须正确 => 1.5
2)另外,我希望SQL命令“WHERE”(其中other_table.status =“finish”)从另一个表扩展。它也不起作用。:-(
select orderid, sum (weight) as totalweight from orderproducts where other_table.status = "finish" group by orderid