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.
with CTE1 as
(
select distinct name as Doctor_name,
row_number() over(order by name asc) as rn
from OCCUPATIONS where OCCUPATION = 'Doctor'
), CTE2 As
(
select distinct name as professor_name,
row_number() over(order by name asc) as rn
from OCCUPATIONS where OCCUPATION = 'Professor'
), CTE3 As
(
select distinct name as Singer_name,
row_number() over(order by name asc) as rn
from OCCUPATIONS where OCCUPATION = 'Singer'
), CTE4 As
(
select distinct name as actor_name,
row_number() over(order by name asc) as rn
from OCCUPATIONS where OCCUPATION ='Actor'
)
select Doctor_name, professor_name, Singer_name, actor_name
from CTE1
full outer join CTE2 on CTE1.rn = CTE2.rn
full outer join CTE3 on CTE2.rn = CTE3.rn
full outer join CTE4 on CTE3.rn = CTE4.rn I am getting runtime error
order by 1, 2, 3, 4
Cookie support is required to access HackerRank
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 →
with CTE1 as ( select distinct name as Doctor_name, row_number() over(order by name asc) as rn from OCCUPATIONS where OCCUPATION = 'Doctor' ), CTE2 As ( select distinct name as professor_name, row_number() over(order by name asc) as rn from OCCUPATIONS where OCCUPATION = 'Professor' ), CTE3 As ( select distinct name as Singer_name, row_number() over(order by name asc) as rn from OCCUPATIONS where OCCUPATION = 'Singer' ), CTE4 As ( select distinct name as actor_name, row_number() over(order by name asc) as rn from OCCUPATIONS where OCCUPATION ='Actor' ) select Doctor_name, professor_name, Singer_name, actor_name from CTE1 full outer join CTE2 on CTE1.rn = CTE2.rn full outer join CTE3 on CTE2.rn = CTE3.rn full outer join CTE4 on CTE3.rn = CTE4.rn I am getting runtime error
order by 1, 2, 3, 4