Skip to Main Content

SQL & PL/SQL

converting rows to columns

BommiNov 8 2022

Hi Experts,
We have a query which fetches data as below
image.pngNow, we need to convert that data as rows to columns and the final output we required should be as below
image.pngCan anyone please help me on how to achieve this.
Please note:
The actual data(as shown in first image) is from a query, not a direct table data.
We have to achieve this only through SQL(please don't ask me why only though query :-) )
I already tried using PIVOT/UNPIVOT. But seems, to use those we need to have a aggregate functions. But in my case, it is purely converting rows to columns blindly.
The PERIOD_FROM and VALUE are not fixed(Our client company's current period starts from 30-Oct. And we need to fetch current + future 6 months data which is as show in images)
Awaiting for your help
Thanks in Advance,
Bommi

Comments
Post Details
Added on Nov 8 2022
7 comments
92 views