• + 0 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