Pivot :-
PIVOT and UNPIVOT are two relational operators that are used to convert a table expression into another. PIVOT is used when we want to transfer data from row level to column level and UNPIVOT is used when we want to convert data from column level to row level. PIVOT and UNPIVOT relational operators are used to generate a multidimensional reporting. Today we will discuss both the operators. PIVOT and UNPIVOT relational operators are used to generate an interactive table that quickly combines and compares large amount of data.
SELECT * FROM
(SELECT year(invoiceDate) as [year], left (datename(month,invoicedate),3 )as [month], _ InvoiceAmount
as Amount FROM Invoice) as InvoiceResult