Learn the SQL data engineers write daily: joins, aggregation, window functions, CTEs, upserts, query plans, and validation checks on real tables.
You have just joined acme-shop's data team. The first pipeline script is written in Python.
Before querying tables, it helps to know how they come to exist and how they change.
Constraints let the database refuse bad data at the door, so you do not have to find it later.
Every query starts from the same three clauses. SELECT names the columns, FROM names the table, and WHERE filters which rows qualify.
CASE WHEN makes a decision per row, like if/elif/else in Python, but as an expression that produces a column value.
Production data is split across tables. A JOIN combines rows from two tables on a matching column.
You have just joined acme-shop's data team. The first pipeline script is written in Python.
Before querying tables, it helps to know how they come to exist and how they change.
Constraints let the database refuse bad data at the door, so you do not have to find it later.
Every query starts from the same three clauses.
CASE WHEN makes a decision per row, like if/elif/else in Python, but as an expression that produces a column value.
Production data is split across tables. A JOIN combines rows from two tables on a matching column.
A query is read top to bottom, but it does not run that way.
GROUP BY collapses many rows into one row per group.
A CTE (Common Table Expression) is a named, temporary result defined with WITH and used inside a larger query.
Pipeline queries filter by date constantly, so handling dates correctly in SQL matters.
A JOIN combines tables side by side. A set operation stacks the results of two queries.
A query that returns correct results but takes four minutes on a large table is not working in production.
Before any transformation or dashboard trusts a table, someone checks that it looks right.
A transaction groups operations so they either all succeed or all roll back. There is no half-changed state in between.
A teammate wants products with more than 600 units sold in total.
📌 Remember: This lab is free and runs on your laptop with Docker, Python, and a terminal. No cloud account is needed.
Syntax at a Glance Choosing Between Common Options
Mistakes to Avoid Using WHERE to filter on an aggregate causes an error every time, because WHERE runs before GROUP BY...
Roles that use the skills in this module.
Data Engineer
Platform Engineer
Not a software engineer sheet. Every problem comes from real DevOps, SRE, Platform and Cloud interviews, from your first script to a system you build yourself.
Open the Coding SheetPython moves and shapes data in pipelines, but SQL is how you inspect tables, transform data inside a warehouse, and prove that results are correct. Running the aggregation where the data lives is usually faster than pulling rows into Python.
WHERE filters individual rows before grouping happens. HAVING filters groups after aggregation, so conditions on COUNT, SUM, or AVG belong there.
A window function calculates something across a set of related rows, such as a rank or a running total, but keeps every original row. GROUP BY, in contrast, collapses rows into one per group.
Pipelines get rerun after failures. An idempotent write, such as an upsert, gives the same result no matter how many times it runs, so a rerun does not create duplicates.