How to Transform Tables with SQL
Reshape data with SQL: nest queries inside queries, combine tables with set operations, count and sum conditionally, and clean dates, numbers and text with PostgreSQL's built-in functions.
- Intermediate level
- 4 modules
- 16 lessons
- 53 tasks and questions
Syllabus
01SubqueriesNest one query inside another: compare rows with a computed value, filter with IN, NOT IN and EXISTS, aggregate in several steps with subqueries in FROM, and write correlated subqueries that run once per row.4 lessons
02Set OperationsCombine the rows of several queries: stack them with UNION and UNION ALL, aggregate across similar tables without losing rows, and compare lists with INTERSECT and EXCEPT.3 lessons
03Conditional AggregatesCount and add up only the rows that meet a condition: measure missing values, sort rows into buckets with CASE, build side-by-side counts with FILTER and SUM(CASE), and turn them into rates.4 lessons
04Date, Number and String FunctionsUse PostgreSQL's built-in functions to compute durations and calendar parts, calculate and round prices, and clean up messy text, then combine every technique from the course in a final project.5 lessons