题解 | #某宝店铺连续2天及以上购物的用户及其对应的天数#
某宝店铺连续2天及以上购物的用户及其对应的天数
https://www.nowcoder.com/practice/63ac3be0e4b44cce8dd2619d2236c3bf
select t.user_id,max(t.aa) as days_count
from (select sales_date ,user_id,dense_rank() over(partition by user_id order by sales_date) as aa from sales_tb) as t
where t.aa>=2
group by t.user_id
dense_rank秒了,考虑显示多个大于二的连续天数,用group配合max去解决