99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2019-03-04 閱讀量: 1665
請問獲取訂單金額前10的用戶的SQL怎么寫?

問題描述:

有如下兩張示例表

訂單金額等于 orderinfo 表里 price*count,每個訂單有多個商品,每個用戶也可能有多個訂單

請問如何通過SQL語句獲取訂單總金額排前10的用戶?

解決方法:

訂單:

orderinfo:

select sum(a.price * a.count) as total, a.order_id, b.user_id 
from `orderinfo` as a, `order` as b
where a.order_id=b.id
group by a.order_id
order by total DESC
limit 10;
5.9738
3
關(guān)注作者
收藏
評論(0)

發(fā)表評論

暫無數(shù)據(jù)
推薦帖子