Brainlag
  1. SQL
  2. Real-world analysis
37/39 lessons

Pivots, rows into columns

30 min4 exercisesPremium

Put two terms side by side, turn one row per mark into one row per student, and see why ELSE 0 quietly wrecks an average.

The skill
Reshape results so values that were spread over many rows sit side by side in columns, ready to compare.
You make
Term-by-term comparisons for a school: subject averages side by side, a mark sheet per student, and who improved most.

Premium lesson

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

Builds on 36 Checking data before you trust it. 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