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

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

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的筛选出来即可。

全部评论

相关推荐

27届学院本誓死冲击...:自我评价和校园经历全删了,荣誉经历只留奖学金,项目也全得换都不如外卖
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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