Your question is Top Campaigns by Rolling CTR. 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.
Amazon DSP reporting needs a ranked view of active advertising campaigns based on click-through rate. Assume the reporting date is 2024-03-30. Write a PostgreSQL query that evaluates the rolling 30-day period from 2024-03-01 through 2024-03-30, inclusive.
ACTIVE and whose delivery date falls within the rolling window.| Column | Type | Description |
|---|---|---|
| campaign_idPK | INTEGER | Unique campaign identifier |
| campaign_name | VARCHAR(150) | Amazon DSP campaign name |
| status | VARCHAR(20) | Campaign state |
| Column | Type | Description |
|---|---|---|
| metric_idPK | INTEGER | Unique daily metric record |
| campaign_id | INTEGER | References campaigns.campaign_id |
| metric_date | DATE | Date of delivery |
| impressions | INTEGER | Delivered impressions |
| clicks | INTEGER | Attributed clicks |