The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question, GAJANANA.
Asked: May 10, 2017 - 8:03 am UTC
Last updated: May 10, 2017 - 8:30 am UTC
Version: 11.1.0.6.0
Viewed 1000+ times
create table emp_det ( name varchar2(15), occupation varchar2(15) ); insert into emp_det values('samantha','doctor'); insert into emp_det values('julia','actor'); insert into emp_det values('maria','actor'); insert into emp_det values('meera','singer'); insert into emp_det values('ashley','professor'); insert into emp_det values('ketty','professor'); insert into emp_det values('jane','actor'); insert into emp_det values('jenny','doctor'); insert into emp_det values('priya','singer'); commit;
doctor professor singer actor jenny ashley meera jane samantha ketty priya julia null null null maria
set null <null> with rws as ( select e.*, row_number() over (partition by occupation order by name) rn from emp_det e ) select * from rws pivot ( min(name) for occupation in ('doctor', 'actor', 'singer', 'professor') ); set null <null> with rws as ( select e.*, row_number() over (partition by occupation order by name) rn from emp_det e ) select * from rws pivot ( min(name) for occupation in ('doctor', 'actor', 'singer', 'professor') );
Analytic SQL got you confused? Check out Connor McDonald's complete video course.