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, Isan.
Asked: June 10, 2021 - 4:04 pm UTC
Last updated: June 14, 2021 - 12:05 pm UTC
Version: Oracle 11g
Viewed 1000+ times
---------------------------------------- | Employee Name | department | Emp Id | ---------------------------------------- | Sam | Sales | 101 | ---------------------------------------- | Sam | Finance | 101 | ---------------------------------------- | Dirk | marketing | 102 | ---------------------------------------- | Dirk | Research | 102 | ----------------------------------------
------------------------------------------------------ | Employee Name | Emp Id | department1 | department2| ------------------------------------------------------ | Sam | 101 | Sales | Finance | ------------------------------------------------------ | Dirk | 102 | marketing | Research | ------------------------------------------------------
with rws as ( select t.*, row_number() over ( partition by emp_id order by department ) rn from ... t ) select * from rws pivot ( max ( department ) dept for rn in ( 1, 2 ) )
Analytic SQL got you confused? Check out Connor McDonald's complete video course.