
SQL for Marketers
Covers Select & Filter Campaign Data, Join Channels to Revenue, Segment Cohorts & Aggregate and more.
“SQL for Marketers” is a 4-lesson course at Teen level, created with soclever, a personal AI teacher. Each lesson takes a few minutes and ends with a check-in question; finish the curriculum and you can take a certificate test to earn a diploma. Try the first lesson without an account — or make your own course on any topic.
What you'll learn
- Select & Filter Campaign Data. Your marketing team has a table called campaigns with columns: campaignname, budget, startdate, and status. You need to pull Q4 data—October through December—for a board review.
- Join Channels to Revenue. A JOIN in SQL combines rows from two tables when they share a matching value—it's how you connect "which ad channel brought in this customer" to "how much revenue did that customer generate."
- Segment Cohorts & Aggregate. You have a users table with signup_month, channel, and converted (1 or 0). Your boss wants to know: which signup month and channel combo had the most conversions?
- Build Attribution Windows. You have a touches table with customerid, touchpoint (email, ad, referral), and touchdate. You have an orders table with customerid, orderdate, and is_repeat.
Lesson 1: Select & Filter Campaign Data
Your marketing team has a table called campaigns with columns: campaign_name, budget, start_date, and status. You need to pull Q4 data—October through December—for a board review.
Start with the simplest query: SELECT campaign_name, budget, start_date FROM campaigns. This pulls three columns for every row in the table. Run it and you'll see all your campaigns, but you've also got Q1, Q2, Q3 noise mixed in.
That's where WHERE comes in. It filters rows before they show up in your results. Add WHERE start_date >= '2024-10-01' AND start_date <= '2024-12-31' and suddenly you're only seeing October, November, December campaigns. Two conditions joined by AND means both have to be true—a row won't show unless the date falls in that range.
The full query looks like this: SELECT campaign_name, budget, start_date FROM campaigns WHERE start_date >= '2024-10-01' AND start_date <= '2024-12-31'.
Read it out loud: "Get me the campaign name, budget, and start date from the campaigns table, but only for rows where the start date is October 1st or later AND December 31st or earlier."
SELECT picks your columns. FROM names the table. WHERE narrows down the rows. That's the pattern. Change the date range, change the columns, change the table—the structure stays the same. You're not guessing anymore; you're asking the database a specific question and it answers with exactly what you asked for.
Questions this course answers
What does a JOIN do in SQL?
A JOIN in SQL combines rows from two tables when they share a matching value.
What is the purpose of the WHERE clause?
The WHERE clause filters rows before they show up in your results.
What does GROUP BY do?
GROUP BY tells SQL to take all rows, bundle them by specified columns, and treat each bundle as one row.
More courses to explore
- The Wire — 4 lessons (Teen level).
- The Fresh Prince — 4 lessons (Teen level).
- Sykes-Picot Agreement — 4 lessons (Teen level).
- NBA Playoffs Explained for Beginners — 4 lessons (Teen level).