SELECT user_id, MIN(activity_date) AS login_dateFROM TrafficWHERE activity='login'GROUP BY user_id;
2 再用90天筛选,并用你group by求数量
SELECT login_date, COUNT(*) AS user_countFROM ( SELECT user_id, MIN(activity_date) AS login_date FROM Traffic WHERE activity='login' GROUP BY user_id) AS tWHERE DATEDIFF("2019-06-30", login_date)<=90GROUP BY login_date;