题解 | #某宝店铺连续2天及以上购物的用户及其对应的天数#
某宝店铺连续2天及以上购物的用户及其对应的天数
http://www.nowcoder.com/practice/63ac3be0e4b44cce8dd2619d2236c3bf
select user_id ,count(*) days_count from ( select distinct user_id ,sales_date ,dense_rank()over(partition by user_id order by sales_date) r from sales_tb ) t group by user_id,date_add(sales_date,interval -r day) having count(*)>=2 order by user_id和某乎那题同样