Your question is Count Users Involved in Calls. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Meta’s calling team wants to measure how many unique users participated in calls on each day, broken out by age bucket and daily active status. A user should be counted if they appear as either the caller or the recipient in the calls table.
Write a PostgreSQL query to return the number of distinct users involved in calls for each date, age_bucket, and daily_active_flag.
caller or the recipient.date.date, age_bucket, then daily_active_flag.| Column | Type | Description |
|---|---|---|
| call_idPK | INT | Unique call identifier |
| caller | BIGINT | User ID of the caller |
| recipient | BIGINT | User ID of the recipient |
| date | DATE | Call date |
| duration | INT | Call duration in seconds |
| Column | Type | Description |
|---|---|---|
| user_id | BIGINT | Meta user ID |
| age_bucket | VARCHAR(20) | Age segment for the user |
| daily_active_flag | BOOLEAN | Whether the user was active on that date |
| date | DATE | Demographic snapshot date |