You are viewing a single comment's thread. Return to all comments →
*Trying without PIVOT *
Select D.Name, P.Name, S.Name, A.Name
from
(Select Name, row_number() over (partition by occupation order by name) id from Occupations where Occupation = 'Doctor') D
full outer join
(Select Name, row_number() over (partition by occupation order by name) id from Occupations where Occupation = 'Professor') P on D.id = P.id
(Select Name, row_number() over (partition by occupation order by name) id from Occupations where Occupation = 'Singer') S on P.id = S.id
(Select Name, row_number() over (partition by occupation order by name) id from Occupations where Occupation = 'Actor') A on S.id = A.id;
Seems like cookies are disabled on this browser, please enable them to open this website
Occupations
You are viewing a single comment's thread. Return to all comments →
*Trying without PIVOT *
Select D.Name, P.Name, S.Name, A.Name
from
(Select Name, row_number() over (partition by occupation order by name) id from Occupations where Occupation = 'Doctor') D
full outer join
(Select Name, row_number() over (partition by occupation order by name) id from Occupations where Occupation = 'Professor') P on D.id = P.id
full outer join
(Select Name, row_number() over (partition by occupation order by name) id from Occupations where Occupation = 'Singer') S on P.id = S.id
full outer join
(Select Name, row_number() over (partition by occupation order by name) id from Occupations where Occupation = 'Actor') A on S.id = A.id;