Skip to content
Advertisement

Display data of a column as a row in Oracle

First of all, I would like to thank you so much for your time in advance.

I have a table as shown below:

I would like to display the data from the above table as shown below:

If no data is present within the COL_DESC for a row then the data from the COL_NAME column needs to be displayed.

I did ask a similar question here, but the criteria for that were fairly complex. I Would like to know how to pivot a single column of data to a row in the simplest way.

Below is the code I tried.

Would really be thankful if anyone could help me with getting this problem solved. Once again thank you so much for your time and help.

Advertisement

Answer

As far i know we cannot use query in pivot clause (it may be possible only with XML when we need the IN as dynamic which I am not much familiar) , however by specifying the col_name explicitly we can achieve it,

Is this what you are looking for ?

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement