0

基本上我有 3 个表,一个包含 id、类型和价格的产品表,一个包含 id、客户 id 的订单表和一个包含 order_id、飞机 id(都连接以制作复合材料)和数量的流程表。

我希望能够显示客户 ID、订单 ID、类型和数量,现在每个客户可以有多个具有相同订单 ID 的订单。然后,我希望能够根据该客户订购的数量计算总数。

有什么我可以使用的想法吗?例如非等连接或内连接、选择语句、求和函数。因为我不确定哪种方法更容易

谢谢 :)

4

1 回答 1

0

Use inner join on the three tables , group by customerId and apply sum() function on quantity . Also whatever columns that you retrieve in Select clause should be mentioned in Group by clause or have some aggregate function applied on them.

于 2013-04-19T17:55:42.173 回答