How would you write a SQL query using window functions to rank campaigns by performance within each advertiser and calculate running totals over time?
Use total conversions as the performance measure, based on daily campaign metrics.
advertiser_id, advertiser_name, campaign_id, metric_date, daily_conversions, total_conversions, campaign_rank, and running_conversions.| Column | Type | Description |
|---|---|---|
| advertiser_idPK | INT | Unique advertiser identifier |
| advertiser_name | VARCHAR(100) | Advertiser display name |
| Column | Type | Description |
|---|---|---|
| campaign_idPK | INT | Unique campaign identifier |
| advertiser_id | INT | Advertiser that owns the campaign |
| campaign_name | VARCHAR(120) | Campaign display name |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INT | Unique daily metric record identifier |
| campaign_id | INT | Campaign associated with the metric |
| metric_date | DATE | Date of the campaign metric |
| conversions | INT | Conversions attributed to the campaign on the date |