create the ORACLE SQL Script statements like below:
drop table temp_table;
create table temp_table as (
select
customer_id ,
max (decode (car_type, 'TOYOTA', 'Y', 'N') as Toyota ,
max (decode (car_type, 'BMW', 'Y', 'N') as BMW ,
max (decode (car_type, 'WV', 'Y', 'N') as WV
from purchase
group by customer_id ) ;
alter table main_cust_table
add (
toyota varchar(2) ,
bmw varchar(2) ,
wv varchar(2) ) ;
update main_cust_table c
set ( toyota, bmw, wv ) =
( select toyota, bmw, wv from temp_table d
where d. customer_id = c. customer_id ) ;
commit;
some customers still have blanks that need to fill 'N'
on those columns
that same as other customer has detail from temp_table
What is the best way to put nvl
?
I don't feel like creating each column for the individual update
script statement.