Menu

Course · Languages & query

SQL

SQL is the core language of data work: querying, transforming and modelling data in warehouses, lakehouses and Spark. Start here before any other tool.

Lessons
23
Interview questions
13
Projects & case studies
11
Reading time
~8 h

About this course

SQL is where most Data Engineering work starts and ends. You use it to explore data, build transformations in a warehouse, define models and validate pipeline output. The same ideas carry over to Spark SQL, Snowflake, BigQuery and Delta Lake, so time spent here pays off across the whole stack.

Work through the lessons in order: query basics, operators and functions, then aggregation, set operations and joins, then subqueries, reshaping and window functions, and finally the time-series, deduplication and slowly changing dimension patterns that appear in almost every pipeline. After that, learn to read a query plan so you can explain why a query is slow.

Your progress

Saved in this browser only

Practise

Course structure

Lessons

Work through the lessons in order. Completed lessons show a tick; lessons you have opened are outlined.

Start here

The complete overview of the course in one read.

  1. SQL Fundamentals: SELECT, WHERE, DISTINCT, ORDER BY and LIMITLearn the core of every SQL query: SELECT and WHERE, aliases, DISTINCT, multi-column ORDER BY and LIMIT, TOP or FETCH FIRST across PostgreSQL, MySQL and SQL Server.Beginner19 min

Beginner

Core concepts you will use every day.

  1. SQL Operators, NULL Handling and CASE ExpressionsWrite correct SQL filters: comparison and logical operators, IN, BETWEEN and LIKE, three-valued NULL logic with COALESCE and NULLIF, and CASE WHEN expressions.Beginner16 min
  2. SQL Functions: Strings, Dates, Type Casting and ArithmeticClean and convert data in SQL: string functions, date arithmetic, CAST and safe casting, integer division and rounding, with names for each major SQL dialect.Beginner20 min
  3. SQL Aggregations: GROUP BY, HAVING and Conditional AggregationHow SUM, AVG, MIN, MAX and COUNT treat NULLs, how GROUP BY sets the grain, WHERE versus HAVING, and conditional aggregation for metrics built in one pass.Beginner18 min
  4. SQL Set Operations: UNION, UNION ALL, INTERSECT and EXCEPTCombine and compare query results with UNION, UNION ALL, INTERSECT and EXCEPT: duplicate handling, NULL behaviour, column matching and data reconciliation patterns.Beginner12 min
  5. SQL Joins: INNER, LEFT, RIGHT, FULL, Self and Cross JoinsPredict the row count of any SQL join: INNER, LEFT, RIGHT and FULL OUTER joins, self joins, cross joins and multi-table joins, plus the filtering and fan-out traps.Beginner25 min

Intermediate

Patterns used in production pipelines.

  1. Semi-Joins, Anti-Joins and LATERAL Joins in SQLFilter with EXISTS and NOT EXISTS instead of joins that duplicate rows, avoid the NOT IN NULL trap, and use LATERAL or CROSS APPLY for per-row top-N and unnesting.Intermediate17 min
  2. SQL Subqueries and CTEs: Derived Tables, Correlated Queries and Temporary TablesWrite subqueries in WHERE, FROM and SELECT, understand correlated subqueries, structure logic with chained CTEs, and know when a temporary table is the better choice.Intermediate18 min
  3. PIVOT, UNPIVOT, GROUPING SETS, ROLLUP and CUBEReshape data in SQL: pivot rows to columns, unpivot columns to rows, handle dynamic pivot columns, and compute subtotals with GROUPING SETS, ROLLUP and CUBE.Intermediate19 min
  4. SQL Window Functions: Ranking, LAG/LEAD and FIRST_VALUELearn SQL window functions: OVER and PARTITION BY, ROW_NUMBER, RANK and DENSE_RANK with ties, NTILE buckets, LAG and LEAD comparisons, and FIRST_VALUE and LAST_VALUE.Intermediate18 min
  5. Window Frames: Running Totals, Moving Averages and PercentilesMaster SQL window frames: running totals, moving averages with ROWS and RANGE, conditional window aggregates, percent of total, CUME_DIST and median with PERCENTILE_CONT.Intermediate24 min
  6. Time-Series SQL: Date Buckets, Calendars, YoY, MoM and Rolling MetricsBuild time-series metrics in SQL: bucket dates, generate calendars to fill gaps, and compute month-over-month, year-over-year and rolling 7 and 30 day figures.Intermediate24 min
  7. Top-N per Group, Deduplication and SCD QueriesSolve three everyday pipeline problems in SQL: top N rows per group with ties, deduplicating to the latest record per key, and querying Type 2 slowly changing dimensions.Intermediate22 min

Advanced

Performance, internals and edge cases.

  1. Recursive CTEs: Hierarchies and Graph Traversal in SQLLearn how recursive CTEs work step by step, then use them to walk org charts, roll up hierarchies and traverse graphs safely without infinite loops.Advanced18 min
  2. Gaps and Islands, Streaks and Sessionization in SQLSolve gaps-and-islands problems with window functions: find missing values, group consecutive rows, measure streaks and split clickstreams into sessions.Advanced17 min
  3. Product Analytics SQL: Retention, Cohorts, Funnels and AttributionWrite the product analytics queries interviewers ask for: day-N retention, cohort matrices, ordered funnels, first and last touch attribution and market basket lift.Advanced18 min
  4. Semi-Structured SQL: JSON, Arrays and Regular ExpressionsParse JSON, flatten nested arrays and extract text with regular expressions in SQL, with PostgreSQL examples and the Snowflake and BigQuery equivalents.Advanced16 min
  5. SQL Query Optimization and Execution PlansA practical process for speeding up slow SQL: read EXPLAIN plans, avoid full table scans, rewrite queries for performance and spot common anti-patterns.Advanced27 min
  6. SQL Indexes: B-tree, Composite, Covering and Bitmap IndexesHow database indexes work and how to design them: B-tree and composite column order, covering indexes, selectivity and cardinality, and bitmap indexing.Advanced23 min
  7. Partitioning, Materialized Views, Columnar Storage and ShardingDesign table partitioning and check pruning in query plans, use materialized views safely, compare row and columnar storage, and choose a sharding key.Advanced24 min
  8. Inside the Query Optimizer: Join Algorithms, Statistics and MemoryHow the optimiser chooses a plan: nested loop, hash and merge joins, table statistics, cardinality estimation, CTE materialisation and spilling to disk.Advanced26 min
  9. SQL at Scale: Window Performance, Skew and Approximate DistinctKeep big queries fast: tune window functions, handle skewed keys in aggregations with two-phase aggregation and salting, and count distinct values with HyperLogLog.Advanced18 min
  10. Transactions, Isolation Levels, Locking and MVCCUnderstand ACID transactions, isolation levels and the anomalies they allow, row locks and deadlocks, and how MVCC lets readers and writers work at the same time.Advanced21 min

Projects and case studies

Apply what you learned and prepare material to discuss in interviews.

Projects

System design case studies

Resources

Cheat sheets

Related courses

Plan your learning

Search
Filter by type