check the following query
SELECT *
FROM (
SELECT *
FROM [YOUR_TABLE_NAME]
) P
PIVOT (
MAX([code])
FOR [sess] IN ([1],[2],[3] ,[4])
) AS PVT
It returns the output as follows
date course 1 2 3 4
---------- ------ ----- ----- ----- -----
2013-01-14 AFF CM NULL CM NULL
2013-01-17 CTF NR NULL NULL NULL
you can modify that by adding the
where
clause for
course column