Your question is Average Channels Per Account. Start with the requirements and the three 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.
Roku's streaming analytics team wants to measure channel breadth across accounts. Write a PostgreSQL query that calculates the average number of distinct Roku channels streamed per eligible account during June 2020.
An eligible account is one with at least one June streaming event linked to a valid Roku channel. Do not count duplicate streams of the same channel more than once, and exclude events outside June or events with missing account or channel references.
2020-06-01 00:00:00 through, but not including, 2020-07-01 00:00:00.avg_channels_per_account, rounded to three decimal places.| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Unique Roku account identifier |
| account_name | VARCHAR(100) | Display label for the account |
| region | VARCHAR(50) | Account's geographic region |
| Column | Type | Description |
|---|---|---|
| channel_idPK | INT | Unique Roku channel identifier |
| channel_name | VARCHAR(100) | Roku channel name |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique streaming event identifier |
| account_id | INT | Roku account associated with the event |
| channel_id | INT | Roku channel streamed during the event |
| streamed_at | TIMESTAMP | Timestamp when streaming occurred |