【大厂真题】SQL19题解 | 查询单日多次下订单的用户信息?
# 需求分析 # SELECT order_date,t.user_id,order_nums,b.vip from ( SELECT DATE_FORMAT(a.order_time,'%Y-%m-%d') as order_date, a.user_id, COUNT(*) order_nums from order_tb a group by DATE_FORMAT(a.order_time,'%Y-%m-%d'),a.user_id having count(*)>=2 ) t inner join uservip_tb b on t.user_id=b.user_id order by order_nums desc