SQL for Data Work
From first SELECT to window functions used in production analytics.
Overview
The SQL course built the way interviews and real teams actually use it: query shape, grain discipline, and the analytical patterns that carry you from reporting to modelling.
Learning objectives
- Write correct, readable queries against relational data
- Reason about grain and cardinality before joining
- Apply window functions to ranking, retention and momentum questions
- Defend your query choices in an interview setting
Prerequisites
- Comfort with spreadsheets
- No prior programming required
Curriculum
Query foundations
Turn business questions into precise, readable SQL.
Relationships and grain
Join tables without silently corrupting your numbers.
Analytical SQL
Ranking, running totals and cohort analysis with window functions.
Capstone project
A D2C retailer cannot agree on revenue numbers: three teams report three totals for the same month.
Revenue intelligence warehouse query pack
Synthetic D2C retail dataset — customers, orders, order_items, refunds (≈250k rows).
Requirements
- Single source-of-truth revenue definition
- Customer, product and monthly reporting views
- Documented grain and join reasoning
- Data quality checks that fail loudly
Architecture
Raw tables → Staging views → Fact & dimension models → Reporting views → Quality tests
Deliverables
- Query pack repository
- README with metric definitions
- Data quality report
- Five-minute walkthrough
Resume bullet points
- “Standardised conflicting revenue definitions into a single tested reporting layer across 250k+ order rows”
- “Eliminated double-counted revenue caused by multi-grain joins and documented the metric contract”
Interview questions
Explain the logical execution order of a SQL query.
FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. It explains alias availability and why filters run before projection.
How do you find the second-highest value per group?
ROW_NUMBER or DENSE_RANK inside a CTE partitioned by the group, then filter the rank outside the CTE.
What is fan-out and how do you prevent it?
Row multiplication from joining a coarser to a finer grain. Pre-aggregate the finer grain first, then join 1:1.
When would you use HAVING instead of WHERE?
HAVING filters after aggregation, so it is used for conditions on aggregate results.
Certificate
DCS Certificate — SQL for Data Work
- Complete all lessons
- Score 80%+ across module quizzes
- Submit the capstone query pack
- Pass the final assessment