题解 | #某宝店铺连续2天及以上购物的用户及其对应的天数#
某宝店铺连续2天及以上购物的用户及其对应的天数
https://www.nowcoder.com/practice/63ac3be0e4b44cce8dd2619d2236c3bf
select distinct s.user_id, count(distinct s.sales_date) from sales_tb s join ( select user_id, sales_date from sales_tb where (user_id, sales_date+1) in (select user_id, sales_date from sales_tb) )t on s.user_id = t.user_id group by s.user_id order by s.user_id