Table Schema
Inspect
Table
| Column | Type |
|---|---|
| user_id | integer |
| activity_date | date |
| product_name | varchar |
Find daily active users across all products.
Table Schema
| Column | Type |
|---|---|
| user_id | integer |
| activity_date | date |
| product_name | varchar |
Sample Data
| user_id | activity_date | product_name |
|---|---|---|
| 101 | 2024-01-01 | Teams |
| 102 | 2024-01-01 | Outlook |
| 101 | 2024-01-02 | Azure |
| 103 | 2024-01-02 | Teams |
| 104 | 2024-01-03 | Outlook |
| activity_date | active_users |
|---|---|
| 2024-01-01 | 2 |
| 2024-01-02 | 2 |
| 2024-01-03 | 1 |
SQL Editor
| activity_date | active_users |
|---|---|
| 2024-01-01 | 2 |
| 2024-01-02 | 2 |
| 2024-01-03 | 1 |
Hints
Solution
Solution is locked until you decide to reveal it. Try the editor first, then open this when you want the reference answer.
SELECT activity_date, COUNT(DISTINCT user_id) AS active_users FROM activity_logs GROUP BY activity_date;
Explanation
Read the expected output columns to determine the final grain.
Aggregate or rank the input rows to calculate the requested metric.
Filter, sort, and alias the final columns to match the output.
Related Questions