题解 | 查询单日多次下订单的用户信息?
查询单日多次下订单的用户信息?
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的筛选出来即可。


查看8道真题和解析