题解 | #某宝店铺折扣率#

某宝店铺连续2天及以上购物的用户及其对应的天数

http://www.nowcoder.com/practice/63ac3be0e4b44cce8dd2619d2236c3bf

with aaa as ( select distinct user_id, dense_rank() over ( partition by user_id order by sales_date ) as days, sales_date from sales_tb ) select aaa.user_id, count(*) as days_count from aaa group by 1, date_add(aaa.sales_date, interval - days day) having days_count >= 2 order by 1

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务