Skip to content

Latest commit

 

History

History
25 lines (24 loc) · 868 Bytes

1141. User Activity for the Past 30 Days I.md

File metadata and controls

25 lines (24 loc) · 868 Bytes

1141. User Activity for the Past 30 Days I

Question Link

3 Solutions

date_sub

# Write your MySQL query statement below
select activity_date day, count(distinct user_id) active_users from Activity
where activity_date between date_sub('2019-07-27',interval 29 day) and '2019-07-27'
group by activity_date

datediff

# Write your MySQL query statement below
select activity_date day, count(distinct user_id) active_users from Activity
where datediff('2019-07-27', activity_date)<30 and activity_date<='2019-07-27'
group by activity_date

><=

# Write your MySQL query statement below
select activity_date day, count(distinct user_id) active_users from Activity
where activity_date > '2019-06-27' and activity_date <= '2019-07-27'
group by activity_date