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

select cust_id, sum(item_price * quantity) total_ordered
from Orders t1 left join OrderItems t2 on t1.order_num = t2.order_num
group by cust_id
order by total_ordered desc;

左联表,过滤掉没有cust_id的订单

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务