courses / sql / level 3

level 3 · expert

advanced
sql.

Write SQL like a professional: windows, recursion, transactions, triggers, indexes and JSON.

  • 28 lessons
  • 7 units
  • 5 h 34 m in all
  • £0, for good

what’s inside.

For people who build things on their own and want code that others trust and can change.

SQL Level 3 picks up where Level 2 left off. In 28 lessons you break big questions into steps, rank and track data with window functions, walk trees with recursion, change data safely with transactions, let triggers and indexes do the work, and read JSON. It ends with a level check: shipping a set of analytics queries that hold up on five different market stalls.

every lesson goes the same way.

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

unit 1

Queries in steps

Break big questions into named steps and combine whole results.

4 lessons · 45 min

  1. Name a step with WITH11 minGive part of a query a name, then use it like a table.
  2. Steps that build on steps12 minChain several named steps into one clear pipeline.
  3. Stack results with UNION11 minPut one result under another, with or without repeats.
  4. Compare two lists11 minFind what two results share and what one has that the other lacks.

unit 2

Window functions

Rank, number and compare rows without losing any of them.

4 lessons · 46 min

  1. A window keeps every row11 minPut a total beside every row instead of squashing the rows.
  2. Number the rows12 minGive every row a position that never wobbles.
  3. Ties and podiums11 minLet tied rows share a place, with or without a gap after.
  4. A window for each group12 minRestart the numbers and totals for every group.

unit 3

Windows over time

Track totals, changes and trends as the days go by.

4 lessons · 48 min

  1. Running totals11 minKeep a total that grows row by row.
  2. Looking back and ahead12 minCompare every row with the one before or after it.
  3. Moving windows12 minSmooth out busy and quiet days with an average that slides.
  4. The best in every group13 minFind the top row, or top few, in every group.

unit 4

Recursion and views

Make rows from nothing, walk family trees and save queries for later.

4 lessons · 49 min

  1. Counting with recursion12 minMake a query repeat itself until a condition stops it.
  2. Filling the gaps13 minMake a full calendar so missing days show up as zero.
  3. Walking a tree13 minFollow bosses and teams through every level at once.
  4. Save a query as a view11 minGive a query a name that everyone can read like a table.

unit 5

Change data safely

Group changes so they all happen or none do, and merge new data cleanly.

4 lessons · 46 min

  1. All or nothing12 minMake several changes count as one, so nothing gets lost halfway.
  2. Changing your mind10 minThrow away a transaction's changes when something looks wrong.
  3. Checkpoints inside a transaction12 minUndo one part of a transaction and keep the rest.
  4. Insert or update12 minAdd new rows and update existing ones in a single statement.

unit 6

Let the database do the work

Get receipts for changes, react to them automatically and find rows fast.

4 lessons · 48 min

  1. See what changed10 minGet the changed rows straight back from an insert, update or delete.
  2. Triggers that react13 minMake the database keep its own records whenever data changes.
  3. Triggers that guard13 minRefuse bad changes with an error message you write yourself.
  4. Indexes and query plans12 minHelp the database find rows fast, and check that it does.

unit 7

Speed, JSON and shipping

Shape indexes to fit your queries, read JSON data and ship a report you trust.

4 lessons · 52 min

  1. Indexes that fit the query13 minBuild indexes on several columns, in the order your queries need.
  2. Reading JSON12 minPull values out of JSON text and skip the broken rows.
  3. Unpacking and building JSON13 minTurn JSON lists into rows, and rows back into JSON.
  4. Shipping a report14 minMake queries that keep working on tomorrow's messy data.
end of level 3 level check: the market stalls' report Build one small project with everything from this level. Pass it and your face levels up. see the check

finished sql?

pick your next language.

see all courses