I am currently attempting to transpose some data inside an SQL query however I can not seem to find a solution using un-pivot. Example of the Data I am working with is
SELECT * FROM (SELECT 'ACCOUNTS' AS Dept
, DATENAME(MONTH, GETDATE()) AS [Month]
, '3254' AS [1st Letter]
, '2544' AS [2nd Letter]
, '1254' AS [3rd Letter]
, '64' AS [4th Letter]
) AS t
I will admit I don't fully understand PIVOT and UNPIVOT fully, however I can not seem to work out if it will work in this query? The desired output would be
Dept |ACCOUNTS
Month |May
1st Letter |3254
2nd Letter |2544
3rd Letter |1254
4th Letter |64
I have seen a lot of solutions on Google but not really for what I am looking for, would a unpivot do the below for me.