Monthly Active Users Count
SQL coding challenge · Difficulty: easy · Topic: DAU / WAU / MAU Metrics · +50 XP
A marketing analytics team wants to know how many unique users were active in each month. Given a table user_activity with columns event_id, user_id, and activity_date, return the month in YYYY-MM format (column month) and the number of distinct users who had at least one activity that month (column mau), one row per month. A user active several times in a month counts once, and the same calendar month in different years is a different month. Row order is not graded; ordering by month just makes the result easier to read.
Example Input
user_activity table:
| event_id | user_id | activity_date | | --- | --- | --- | | 1 | 101 | 2024-01-05 | | 2 | 102 | 2024-01-07 | | 3 | 101 | 2024-01-20 | | 4 | 103 | 2024-02-01 | | 5 | 104 | 2024-02-03 | | 6 | 101 | 2024-02-15 | | 7 | 105 | 2024-02-20 |
Expected Output
| month | mau | | --- | --- | | 2024-01 | 2 | | 2024-02 | 4 |
What this SQL challenge teaches you
“Monthly Active Users Count” is a easy-level SQL challenge focused on DAU / WAU / MAU Metrics. Working through it gives you hands-on practice with aggregate, date, mau, group by, date_format — the kind of transformation you are asked to write in real data engineering work and in technical interviews. You can solve it directly in the browser: the dataset is pre-loaded, so you write the query or DataFrame code, run it, and compare your output against the expected result immediately.
Concepts covered
- aggregate
- date
- mau
- group by
- date_format
How to approach it
If you get stuck, work through these steps in order before looking at a full solution — each one narrows the problem down:
- 1 ≤ number of rows ≤ 200000
- Each user_id appears between 1 and 10 times
- activity_date values are valid dates in YYYY-MM-DD format
- Return columns: month (VARCHAR), mau (INT), ordered by month ASC
- All months present in the data must appear in the result
How to practise it on PySpark.in
Open the challenge, write your SQL query in the editor and press Run to execute it against the sample dataset. Submitting checks your output against every test case, including hidden ones, so you find out straight away whether your logic holds up. You can retry as often as you like, and each solved challenge adds to your XP.
Related SQL challenges
- Calculate DAU, WAU, MAU for an E-commerce Platform
- Top 3 Products per Category
- Running Total Revenue
- Find Duplicate Emails
- Median Salary per Department
- Second Highest Salary
Helpful resources
Frequently asked questions
Do I need to install Spark or a database to solve this?
No. The SQL environment runs in your browser with the sample data already loaded, so there is nothing to install or configure.
Is this challenge free?
Yes - the problem, the sample dataset, the hints and unlimited test runs are free.
What level is it?
It is rated easy and covers DAU / WAU / MAU Metrics.