Lesson 3.4 · Pro
Unpivot: turn columns into rows
Reshape a wide report (day1, day2, day3...) into a long table that's easy to chart and filter.
In this lesson
- Stack one SELECT per column with UNION ALL
- The shorter way: CROSS JOIN LATERAL (VALUES ...)
- Then query the long table
Go Pro to read this lesson
Pro unlocks every lesson and practice problem in SQL, Python, pandas and NumPy, with answers and step-by-step explanations.