good sql server pivot example

SELECT tID , [Country] , [Day] , [Month]

FROM ( SELECT t2.tID , t1.ColName , t2.Txt FROM Table1 AS t1 JOIN Table2
AS t2 ON t1.ColId = t2.ColID )

p PIVOT ( MAX([Txt]) FOR ColName IN ( [Country], [Day], [Month] ) ) AS pvt ORDER BY tID ;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.