Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get dynamic column name in PL/SQL?

marlborocatJan 13 2017 — edited Jan 13 2017

I have a table like this

NUMBER

NAME

1

AA

2

BB

3

CC

4

DD

How to make select result like this using PL/SQL?

NAME_1

NAME_2

NAME_3

NAME_4

AA

BB

CC

DD

Please note that the NAME_1,2,3,X  it should be dynamic based on number column. It could be only number 1,2, in that case it will be like this

NAME_1

NAME_2

AA

BB

If it’s 1,2,3 , three rows, it will be

NAME_1

NAME_2

NAME_3

AA

BB

CC

This post has been answered by Paulzip on Jan 13 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2017
Added on Jan 13 2017
6 comments
1,636 views