April spend and cost per click for search and social
The task
The paid team reviews campaigns on the search and social channels for April 2025 (from 2025-04-01 to 2025-04-30 inclusive, by ad_daily.day).
Return one row for every campaign on those two channels, even if it served no ads in April:
campaign_iddays_served: the number ofad_dailyrows in April (0 if none)spend: totalspendin April, 0 if noneclicks: totalclicksin April, 0 if nonecost_per_click:spend / clicks, rounded to 2 decimal places, or NULL when there were no clicks
Sort by campaign_id.
Expected output
campaign_iddays_servedspendclickscost_per_click- Sorted by campaign_id ascending.
- Numbers rounded to 2 decimal places.
- Checked on the sample and on 2 hidden datasets. How grading works
Tables Marketing team · click a name to insert it
campaigns10 rows in the sample
One row per campaign. Key: campaign_id.
| int | Unique id. | |
| text | Name. | |
| text | search, social, video, email or affiliate. | |
| date | First day live. | |
| date | Last day live. NULL if still running. | |
| numeric(10,2) | Budget per day, USD. |
ad_daily969 rows in the sample
One row per campaign per day it served ads. Days with no delivery have no row. Key: campaign_id, day.
| int | The campaign. | |
| date | The day. | |
| int | Times an ad was shown. | |
| int | Clicks. | |
| numeric(10,2) | Money spent, USD. |
signups2,108 rows in the sample
One row per new user. campaign_id is the campaign credited with the sign-up. Key: user_id.
| int | Unique id. | |
| timestamp | When they signed up (UTC). | |
| int | Credited campaign. NULL for organic sign-ups. | |
| text | Two-letter country code. |
purchases2,294 rows in the sample
One row per paid order by a user. Key: purchase_id.
| int | Unique id. | |
| int | Buyer. | |
| timestamp | When (UTC). | |
| numeric(10,2) | Order value, USD. |
Related questions
- Daily spend against sign-ups for one campaignhard
- Email-referred customers and their completed orderseasy
- Headcount by department, empty and unassigned includedeasy
- Invoiced amount by the plan active on the issue datemedium
- Organic sign-ups during each campaign's runmedium
- Sign-ups per campaign who placed a large ordereasy
Loading the editor and PostgreSQL
Loading the editor and PostgreSQL