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

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

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

经过这几次练习,我总结以下: 什么时候join需要select条件呢 当要筛选的元组需要用到sum时,必须筛选一次并且要按照某个元组分组,因为sum的不止一项。若只有一项时,不需要sum,可以直接筛选、join 以下是代码:

select cust_name, total_price
-- 用到sum时,需要筛选出分组的元组和sum计算,此时join需要select
from 
(
    select order_num, sum(item_price *quantity)  total_price
    from OrderItems
    group by order_num
)oi
join Orders o on oi.order_num= o.order_num
join Customers c on o.cust_id= c.cust_id
where  total_price >= 1000
order by total_price;
全部评论

相关推荐

身边有人上海、深圳 6、7k 都去了,真就带薪上班了。
程序员小白条:木的办法, 以后越来越差,还是家附近宅着吧,毕业的人越来越多,岗位都提供不出来,经济又过了人口红利期
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-07 11:30
仁者伍敌:kpi都懒得刷了属于是
点赞 评论 收藏
分享
06-28 22:48
已编辑
广东金融学院 Java
小浪_Coding:学院本+这俩项目不是buff叠满了嘛
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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