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

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

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

# 方法1:内连接
select  c.cust_name,sum(oi.quantity*oi.item_price)total
from Customers c,Orders o,OrderItems oi
where c.cust_id=o.cust_id
and o.order_num=oi.order_num
group by  c.cust_name
having total>=1000;

# 方法2:先筛选后链接
select c.cust_name,cus_total.total
from orders o,
     customers c ,
     (select order_num,sum(item_price*OrderItems.quantity)total
        from orderitems
        group by order_num
      having sum(item_price*OrderItems.quantity)>=1000) as cus_total
where cus_total.order_num=o.order_num
and o.cust_id=c.cust_id;

全部评论

相关推荐

秋招不是要开始了吗,我都打算润了,看大家还在找不敢润了
一条从:因为不是人人都像佬一样有实习像我们这种二本仔秋招没有实习也是白忙活
点赞 评论 收藏
分享
兄弟们你们进大厂靠的是什么项目啊
DOTPHTP:课设改。其实项目什么的如果不是实习里面的生产项目的话,建议✍️那种自己想要做的。突出个人自驱力,而不是为了找工作不得不随波逐流这种
点赞 评论 收藏
分享
05-09 13:22
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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