SELECT, WHERE, GROUP BY
Aggregate campaign data.
The Three Verbs
Almost every marketing metric is built from three clauses: SELECT chooses columns, WHERE filters rows, and GROUP BY collapses rows into segments.
Master this trio and you can answer most day-to-day analytics questions on your own.
SELECT channel, SUM(revenue) AS revenue
FROM orders
GROUP BY channel;SELECT: Picking Columns
SELECT lists what you want back. You can rename columns with AS to make output readable, and compute new values inline.
Keep result sets lean: pull only the columns you actually need, especially on large tables.
SELECT campaign_id AS campaign,
spend,
spend * 1.2 AS spend_with_fees
FROM campaigns;All lessons in this course
- Why Marketers Learn SQL
- SELECT, WHERE, GROUP BY
- Joining Marketing Tables
- Cohort and Funnel Queries