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

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

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

select c.cust_name, A.total_price
from Customers c 
inner join (select o.cust_id, sum(oi.item_price*quantity*1.000) total_price
from OrderItems oi
inner join Orders o
on oi.order_num = o.order_num
group by o.cust_id
) A
on A.cust_id = c.cust_id
where A.total_price >= 1000
order by A.total_price
#数据每一行都能互相匹配,所以连接方式对结果并没有什么影响

全部评论

相关推荐

2 收藏 评论
分享
牛客网
牛客企业服务