Explain it in 60 seconds
Pivot and unpivot
Data Engineering · SQL · Intermediate
How do you pivot and unpivot data in SQL?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Pivot turns row values into columns, like months into columns.
- Conditional aggregation with SUM(CASE ...) works in any database.
- Some engines have PIVOT and UNPIVOT syntax.
- Unpivot turns columns into rows, useful for wide spreadsheet-like data.
- Dynamic pivots need dynamic SQL or Jinja because columns must be known.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.