Unpivot Quarterly Columns
Medium
Pivot & Unpivot
The table stores one column per quarter. Turn it into rows with the columns product, quarter and amount, ordered by product then quarter.
Table schema
Sales(product VARCHAR(20), q1 INT, q2 INT, q3 INT, q4 INT)Sample data
product | q1 | q2 | q3 | q4
Pen | 10 | 20 | 30 | 40
Book | 1 | 2 | 3 | 4
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.