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

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

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

select date(order_tb.order_time) as order_date,order_tb.user_id,count(order_tb.user_id) as order_nums,uservip_tb.vip
from order_tb join uservip_tb where order_tb.user_id=uservip_tb.user_id
group by date(order_tb.order_time),order_tb.user_id having order_nums>1
order by order_nums desc;

连续两次分组:对时间进行分组的基础上再对用户进行分组,然后使用having 语句将单日用户下单次数大于1的筛选出来即可。

全部评论

相关推荐

对空六翼:你真幸运,碰见这么好的人,不像我,秋招的时候被室友骗进cx了
实习好累,可以辞职全力准...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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