Loading the editor…
Count the leads captured by each campaign.
Growth wants volume next to the campaign name. A campaign with several submissions from the same email still captured several lead rows.
Return campaign and leads. Count lead rows per campaign. Sort by leads descending, then campaign name.
| id | name | channel | spend | started_on |
|---|---|---|---|---|
| 1 | Spring Search | paid_search | 4200 | 2025-03-01 |
| 2 | Lifecycle Email | 800 | 2025-03-01 | |
| 3 | Podcast Tour | podcast | 2500 | 2025-04-01 |
| id | campaign_id | status | created_at | |
|---|---|---|---|---|
| 1 | 1 | ada@example.com | new | 2025-03-05 |
| 2 | 1 | ada@example.com | qualified | 2025-03-08 |
| 3 | 2 | lin@example.com | new | 2025-03-11 |
Ctrl or Cmd + Enter runs the query. The database resets on every run.
Run the query to see rows from the sample database.
Next exercise: Friendly order status labels
Related: Campaigns by spend, Campaigns with at least two leads