题解 | 查询订单

查询订单

https://www.nowcoder.com/practice/5ae7f48dc94f4a76b0ade40b70caf308

select 
t1.order_id
,t2.customer_name customer_name
,t1.order_date  order_date
from 
(
	select
	order_id
	,customer_id
	,order_date
	,rank()over(partition by customer_id order by order_date desc) r 
	from orders
) t1
join customers t2
on t1.customer_id = t2.customer_id
where r = 1
order by 2

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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