PIVOT and UNPIVOT in Sql Server

SELECT *
FROM #CourseSales
PIVOT(SUM(Earning)
      FOR Course IN ([.NET], Java)) AS PVTTable


http://sqlhints.com/2014/03/10/pivot-and-unpivot-in-sql-server/