May 11, 2022 at 12:53 pm
Hi everybody, i have a table in SQl Server 2014 like the following:
And i woul like to abtain an output like this:
any help is appreciated.
Thank you
May 11, 2022 at 2:29 pm
Just a suggestion to a newbie that took the time to nicely format their question... if you were to post your question with some readily consumable data, you'd already have an answer. Welcome aboard and please see the article at the first link in my signature line below for what I'm talking about and why.
--Jeff Moden
May 11, 2022 at 2:37 pm
SELECT ca.*
FROM dbo.your_table_name
CROSS APPLY (
SELECT Sector, 2023 AS Period, [2023] AS Value
UNION ALL
SELECT Sector, 2024, [2024]
UNION ALL
SELECT Sector, 2025, [2025]
) AS ca
ORDER BY Sector, Period
SQL DBA,SQL Server MVP(07, 08, 09) "Money can't buy you happiness." Maybe so, but it can make your unhappiness a LOT more comfortable!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply