Taking data from one column and spread it out into multiple columns
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