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
Change is inevitable... Change for the better is not.
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) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply