2
我还没有在现有问题中找到类似的表结构,所以我希望有人能够提供帮助。Mysql查询计算SKU销售的产品总数
我想总结一下产品的订单总量及其与下面两个表的结构收入:
orders
trans_id | account_id | type
1 | 1 | credit
2 | 1 | credit
3 | 1 | void
4 | 2 | credit
orderlineitems
order_trans_id | sku | quantity | unitPrice
1 | sku1 | 1 | 5
1 | sku2 | 3 | 3
2 | sku1 | 5 | 5
4 | sku1 | 2 | 22.99
所以我想总结一下所有的数量对于一个给定ACCOUNT_ID其中类型是信用。所以我应该有:
Account ID = 1
sku | quantity
sku1 | 6
sku2 | 3
Account ID = 2
sku | quantity
sku1 | 2