• You can use the PIVOT funtion to do this. The PIVOT is clearly explained here: http://www.databasejournal.com/features/mssql/converting-rows-to-columns-pivot-and-columns-to-rows-unpivot-in-sql-server.html

    Over here https://www.simple-talk.com/sql/t-sql-programming/questions-about-pivoting-data-in-sql-server-you-were-too-shy-to-ask/ can also some nice explanation be found.

    If you still have doubts/questions about how to solve your issue, please post DDL with a sample of the base-data. That makes it more easy for us to provide a complete solution to you.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **