Here is a example of Pivot table in SQL
Here is my original table
SELECT UserName,[One],[Two],[Three],[Four]
FROM
(SELECT UserName, class, grade FROM Testing) Tbl
PIVOT
(
Max(grade)
FOR Class IN ([One],[Two],[Three],[Four])
) PivotTable
Here is my original table
After applying the following pivot query. The result looks like the following picture.
FROM
(SELECT UserName, class, grade FROM Testing) Tbl
PIVOT
(
Max(grade)
FOR Class IN ([One],[Two],[Three],[Four])
) PivotTable