题解 | #确定最佳顾客的另一种方式(二)#

确定最佳顾客的另一种方式(二)

https://www.nowcoder.com/practice/b5766f970ae64ac7944f37f5b47107aa

-- 简单写下思路,先写一个子查询查询出分组后的订单和,然后再查询对结果进行排序
select
    cust_name,
    total_price
from
    (
        select
            c.cust_name,
            sum(round(o.item_price * o.quantity, 3)) as total_price
        from
            OrderItems as o
            join Orders as r on o.order_num = r.order_num
            join Customers as c on r.cust_id = c.cust_id
						group by c.cust_name
    ) as t
where
    total_price >= 1000
order by
    total_price

全部评论

相关推荐

04-02 22:40
已编辑
电子科技大学 后端
谢谢大家啦!!!
坚定的芭乐反对画饼_许愿Offer版:有鹅选鹅,没鹅延毕
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务