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 |