题解 | #某宝店铺连续2天及以上购物的用户及其对应的天数#
某宝店铺连续2天及以上购物的用户及其对应的天数
https://www.nowcoder.com/practice/63ac3be0e4b44cce8dd2619d2236c3bf
select user_id,count(user_id) days_count from (select *,sales_date-row_number() over(partition by user_id order by sales_date) sss /*连续登录天数通用,相减相等个数即连续登录天数*/ from (select distinct user_id,sales_date from sales_tb) cb) cb2 group by user_id,sss having days_count >= 2 order by user_id