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

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

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

#子查询
select cust_id,total_order
from Orders,(select order_num,sum(item_price*quantity) as total_order from OrderItems
group by order_num)as tt
where tt.order_num=Orders.order_num
order by total_order desc
#自然连接
select cust_id,total_order
from Orders 
natural join
(select order_num,sum(item_price*quantity) as total_order from OrderItems
group by order_num)as tt
where tt.order_num=Orders.order_num
order by total_order desc
#左连接
select cust_id,total_order
from Orders 
left join
(select order_num,sum(item_price*quantity) as total_order from OrderItems
group by order_num)as tt
on tt.order_num=Orders.order_num
order by total_order desc
#内连接
select cust_id,total_order
from Orders 
inner join
(select order_num,sum(item_price*quantity) as total_order from OrderItems
group by order_num)as tt
on tt.order_num=Orders.order_num
order by total_order desc

全部评论

相关推荐

king122:专业技能不要写这么多,熟悉和熟练你经不住问,排版有些难看,中间的空隙搞小一点,项目描述的话感觉是从课程中抄下来的,改一改吧,不然烂大街了,每个项目都写一两点,用什么技术实现了什么难点,然后再写一些数字上去像时间又花了90%这样,这样面试会多一些,如果觉得自己的项目还是不够用的话,我有几个大厂最近做过的实习项目,感兴趣的话可以看我简介中的项目地址
点赞 评论 收藏
分享
05-11 20:45
门头沟学院 Java
有担当的灰太狼又在摸...:零帧起手查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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