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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Oracle Pivot

user9311128May 26 2021

I have employee name and salary date fields in a table having only these two values. Need the salary date output in pivot row format, can anyone please help? Pasted the sample queries and the expected output format below.

create table testdaterows (empname varchar2(30), salary_dt date);
insert into testdaterows values ('peter', to_date('01/01/2021','MM/DD/YYYY'));
insert into testdaterows values ('peter', to_date('02/01/2021','MM/DD/YYYY'));
insert into testdaterows values ('peter', to_date('05/01/2021','MM/DD/YYYY'));
insert into testdaterows values ('rachael', to_date('01/10/2021','MM/DD/YYYY'));
insert into testdaterows values ('rachael', to_date('03/10/2021','MM/DD/YYYY'));
insert into testdaterows values ('rachael', to_date('04/10/2021','MM/DD/YYYY'));
insert into testdaterows values ('Anita', to_date('02/15/2021','MM/DD/YYYY'));
insert into testdaterows values ('Anita', to_date('03/15/2021','MM/DD/YYYY'));
commit;
select * from testdaterows;
Empname Salary_dt
peter 1/1/2021
peter 2/1/2021
peter 5/1/2021
rachael 1/10/2021
rachael 3/10/2021
rachael 4/10/2021
Anita 2/15/2021
Anita 3/15/2021

Expected Output:
image.png
--Thanks

This post has been answered by Frank Kulash on May 26 2021
Jump to Answer

Comments

Processing

Post Details

Added on May 26 2021
2 comments
155 views