题解 | 查询单日多次下订单的用户信息?

查询单日多次下订单的用户信息?

https://www.nowcoder.com/practice/9958aed1e74a49b795dfe2cb9d54ee12

with tiaojian as (
select 
t.order_date,
t.user_id,
order_nums
from(
select 
date(order_time) as order_date,
user_id,
count(order_id) as order_nums,
dense_rank()over(partition by date(order_time) order by count(order_id) desc) as pdiff
from order_tb
group by user_id,date(order_time)
having count(order_id)>1
) as t 
where
t.pdiff=1
)


select 
t.order_date,
t.user_id,
t.order_nums,
ub.vip
from tiaojian t left join uservip_tb ub
 on t.user_id=ub.user_id
 order by t.order_nums desc

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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