Write a SQL query using window functions to identify the top-performing ad campaigns by daily reach for Samsung Ads.
Use the provided campaign and daily reach data. Return the two highest-ranked campaigns for each date, including ties at the second rank.
reach_date, campaign_id, campaign_name, daily_reach, and daily_rank.reach_date, daily_rank, then campaign_id.| Column | Type | Description |
|---|---|---|
| campaign_idPK | INT | Unique Samsung Ads campaign identifier |
| campaign_name | VARCHAR(150) | Display name of the campaign |
| advertiser_name | VARCHAR(150) | Advertiser associated with the campaign |
| Column | Type | Description |
|---|---|---|
| reach_record_idPK | INT | Unique daily reach record identifier |
| campaign_id | INT | Campaign associated with the reach record |
| reach_date | DATE | Date on which reach was recorded |
| reach | BIGINT | Number of reached devices or viewers in the record |