PIVOT — rotate rows to columns.
Purpose:
Example:
1-- Sales by month2SELECT * FROM (3 SELECT product, month, amount FROM sales4)5PIVOT (6 SUM(amount)7 FOR month IN ('Jan', 'Feb', 'Mar')8);910Result:11Product | Jan | Feb | Mar12Widget | 1000 | 1200 | 150013Gadget | 800 | 900 | 1100
BA use: