https://www.techmixing.com/2012/04/pivot-table-in-sql-server.html
Pivot and Unpivot table in SQL SERVER