Brainlag
  1. SQL
  2. Core
16/39 lessons

Joining a table to itself

30 min4 exercisesPremium

Join a table to itself with two aliases to see who referred each player, count recruits, compare two rows, and match remixes to their originals.

The skill
Follow a column that points at another row of the same table, and compare the two rows side by side.
You make
A referral report for a game, a recruiters leaderboard, and remixes that beat the original.

Premium lesson

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

Builds on 15 Joining three tables or more. Free to try: SQL Foundations and the playground.

Step 1 of 7
exercise_1.sql

You've reached the good stuff.

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

SQLite