题解 | #返回每个顾客不同订单的总金额#

返回每个顾客不同订单的总金额

http://www.nowcoder.com/practice/ce313253a81c4947b20e801cd4da7894

法一:
select cust_id, total_order
from (select order_num, sum(quantity * item_price) as total_order
    from OrderItems
    group by order_num) t
inner join Orders o1
on o1.order_num = t.order_num
order by total_order desc
法二:
select cust_id, sum(quantity * item_price) as total_order
from OrderItems o1, Orders o2
where o1.order_num = o2.order_num
group by cust_id
order by total_order desc
全部评论

相关推荐

11-21 11:26
已编辑
门头沟学院 前端工程师
Apries:这个阶段来说,很厉害很厉害了,不过写的简历确实不是很行,优势删掉吧,其他的还行
点赞 评论 收藏
分享
头像
11-06 10:58
已编辑
门头沟学院 嵌入式工程师
双非25想找富婆不想打工:哦,这该死的伦敦腔,我敢打赌,你简直是个天才,如果我有offer的话,我一定用offer狠狠的打在你的脸上
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务