25 April 2012

How to Use Pivot Table

Function untuk membentuk row menjadi column dengan menambahkan fungsi aggregate seperti
count, min, max, sum.


-----start-----
SELECT * FROM Sample_Pivot AS a
PIVOT
(
 COUNT(EmployeeID)
 FOR DepartmentName IN ([Production], [Engineering], [Marketing])
)
AS n
ORDER BY ShiftName
-----end-----