diff --git a/1141-user-activity-for-the-past-30-days-i.sql b/1141-user-activity-for-the-past-30-days-i.sql index 8b46b0d..3174584 100644 --- a/1141-user-activity-for-the-past-30-days-i.sql +++ b/1141-user-activity-for-the-past-30-days-i.sql @@ -1,5 +1,13 @@ # Write your MySQL query statement below -select activity_date as day, count(distinct user_id) as active_users -from Activity -where datediff('2019-07-27', activity_date) < 30 -group by activity_date; +SELECT + activity_date AS day, + COUNT(DISTINCT user_id) AS active_users +FROM + Activity +WHERE + DATEDIFF('2019-07-27', activity_date) < 30 + AND activity_date <= '2019-07-27' +GROUP BY + activity_date +ORDER BY + day;