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

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

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

全部评论

相关推荐

点赞 评论 收藏
分享
程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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