1245. User Activity for the Past 30 Days I
My accepted SQL solution to LeetCode problem 1245, User Activity for the Past 30 Days I, running in 561ms.
- Difficulty: Easy
- SQL
- Runtime 561ms
- Memory 0.0B
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
SQL
Accepted on LeetCode — runtime 561ms, memory 0.0B, accepted 2025-12-29.
SELECT activity_date AS day, COUNT(DISTINCT user_id) AS active_users
FROM Activity
WHERE activity_date BETWEEN DATE_SUB('2019-07-27', INTERVAL 29 DAY) AND '2019-07-27'
GROUP BY activity_date