Your question is SQL on Advertiser Metrics. 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.
Reddit Ads needs a weekly revenue report for advertiser performance. Assume the report is run for the week beginning 2025-02-17, so “last week” is 2025-02-10 through 2025-02-16, inclusive.
Write one PostgreSQL query that returns the daily performance of the advertiser with the highest total revenue last week. Include every day in the week, including days with no revenue for that advertiser. Also include the percentage of all advertisers whose total revenue last week exceeded $40. Advertisers with no revenue during the week must remain in the denominator.
ROW_NUMBER(), breaking ties by advertiser_id.| Column | Type | Description |
|---|---|---|
| advertiser_idPK | INT | Unique advertiser identifier |
| advertiser_name | VARCHAR(100) | Advertiser display name |
| Column | Type | Description |
|---|---|---|
| revenue_idPK | INT | Unique revenue record identifier |
| advertiser_id | INT | Advertiser associated with the revenue |
| revenue_date | DATE | Date on which revenue was recorded |
| revenue | NUMERIC(10,2) | Revenue amount in US dollars |