Your question is SQL With Window Functions. 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.
TikTok's creator analytics team wants to identify the strongest public videos for each active creator. Write a PostgreSQL query that calculates January engagement and ranks videos within each creator.
video_id.| Column | Type | Description |
|---|---|---|
| creator_idPK | INT | Unique creator identifier |
| handle | VARCHAR(50) | TikTok creator handle |
| creator_tier | VARCHAR(20) | Creator classification |
| is_active | BOOLEAN | Whether the creator is active |
| Column | Type | Description |
|---|---|---|
| video_idPK | INT | Unique video identifier |
| creator_id | INT | Creator who owns the video |
| caption | VARCHAR(200) | Video caption |
| published_at | DATE | Date the video was published |
| visibility | VARCHAR(20) | Visibility status of the video |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INT | Unique metrics record identifier |
| video_id | INT | Video associated with the metrics |
| metric_date | DATE | Date of the daily metrics |
| likes | INT | Number of likes |
| comments | INT | Number of comments |
| shares | INT | Number of shares |