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!

Taking data from one column and spread it out into multiple columns

user12296489Dec 1 2009 — edited Dec 1 2009
I have a table that I wish to take the multiple values out of one column and stick each into its own column..

The data looks like this:

subscriber id benefit plan
12345 Med
12345 Drg
98765 Med
98765 Drg

I want it to look like:

subscriber_id pc_med pc_drg
12345 Med Drg
98765 Med Drg

Without doing an 2 additional (update) queries..the below is what I thought of doing, but obviously it doesn't work as there can be only one row returned in doing a subquery..

any ideas are greatly appreciated..

select distinct subscriber_id,
(select grp07_benefit_plan from martin_7265_anoc
where grp07_benefit_plan_type = 'MEDICAL ') pc_med,
(select grp07_benefit_plan from martin_7265_anoc
where grp07_benefit_plan_type = 'DRUG ') pc_drg
from martin_7265_anoc
This post has been answered by Centinul on Dec 1 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 29 2009
Added on Dec 1 2009
3 comments
1,143 views