We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
select doctor,professor,singer,actor from
(select *
from (select Name, occupation, (ROW_NUMBER()
OVER (PARTITION BY occupation ORDER BY name)) as row_num from occupations order by name asc)
pivot
(
min(name)
for occupation
in ('Doctor' as doctor,'Professor' as professor,'Singer' as singer,'Actor' as actor))
order by row_num);
This works for me in Oracle db.
Occupations
You are viewing a single comment's thread. Return to all comments →
select doctor,professor,singer,actor from (select * from (select Name, occupation, (ROW_NUMBER() OVER (PARTITION BY occupation ORDER BY name)) as row_num from occupations order by name asc) pivot ( min(name) for occupation in ('Doctor' as doctor,'Professor' as professor,'Singer' as singer,'Actor' as actor)) order by row_num);
This works for me in Oracle db.