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

select
    cust_id,
    sum(total_ordered) total_ordered
from
    (
        select
            cust_id,
            item_price * quantity total_ordered
        from
            OrderItems ori
            join Orders ord on ori.order_num = ord.order_num
    ) a
group by
    cust_id
order by
    total_ordered desc

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务