Is it actually possible to rotate a T-SQL (2005) so that (for the sake of argument) the values of the first column's rows become the titles of the output table's columns?
I realise this is not really what PIVOT is for, but it's what I need - the ability to request a table where the columns are not known before-hand because they have been entered as values into a table.
Even a hack would be nice, tbh.
A slightly better pivot query is as follows:
I prefer the style of a Common Table Expression (CTE) over a derived table as I think it is easier to understand. Itzik does too, as he recommends this style in his book Querying Microsoft SQL Server 2012.
Itzik Ben-Gan's example on how to build dynamic PIVOT, I highly recommend his Inside Microsoft SQL Server 2008: T-SQL Programming book