Brainlag
  1. SQL
  2. Advanced
21/39 lessons

CTEs, naming the steps with WITH

30 min6 exercisesPremium

Break a hard SQL question into named steps with WITH (common table expressions), chain several steps, and turn a nested subquery into something you can read.

The skill
Break a hard question into named steps you can read and check one by one.
You make
Listener averages, skip rates and stand-out songs for a music service.

Premium lesson

£7.99 a month or £59 a year. Cancel any time.

Builds on 20 EXISTS and subqueries that look outside. Free to try: SQL Foundations and the playground.

Step 1 of 9
exercise_1.sql

You've reached the good stuff.

6 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.

SQLite