SELECT user_id,count(ndt) days_count from (SELECT *,sales_date - DENSE_RANK() OVER(PARTITION BY user_id ORDER BY sales_date) ndt from (SELECT DISTINCT sales_date,user_id FROM sales_tb) t )s GROUP BY user_id,s.ndt HAVING count(ndt) >=2 ORDER BY user_id 我认为需要对user_id,sales_date进行去重处理(存在一个用户一天购买了两次...