I'm trying to flatten a set of data from a SQL query (using MS SQL Server) and I need to do it twice.
This is the example data I have.
This is the data I would like to show
I managed to get one height and one area for each building using PIVOT but what I need is to pivot again in order to have one row for every building that contains all the related data.
I think the solution requires the use of both PIVOT and CROSS APPLY but I cannot find the right way to use them.
Thanks for your help!