I'm trying to order every column by value in alphabetical order and then by followed by NULL. However, it is not working. I tried to place order by at each query before fully joined , but it doesn't allow so what could be some possible ways to achieve the goal?
Select t1.Name AS Doctor, t2.Name AS Professor, t3.Name AS Singer,t4.Name AS Actor
FROM (
SELECT Name
FROM Occupation
Where Occupation ='Doctor'
) t1
FULL JOIN
(
SELECT Name
FROM Occupation
Where Occupation ='Professor'
) t2
on t1.Name=t2.Name
FULL JOIN
(
SELECT Name
FROM Occupation
Where Occupation ='Singer'
) t3
on t1.Name=t3.Name
FULL JOIN
(
SELECT Name
FROM Occupation
Where Occupation ='Actor'
) t4
on t1.Name=t4.Name
ORDER BY Doctor ASC, Professor ASC, Singer ASC, Actor ASC
Wrong Result:
Doctor Professor Singer Actor
-------------------------------------------
NULL NULL NULL Jane
NULL NULL NULL Julia
NULL NULL NULL Maria
NULL NULL Meera NULL
NULL NULL Priya NULL
NULL Ashley NULL NULL
NULL Christeen NULL NULL
NULL Ketty NULL NULL
Jenny NULL NULL NULL
Samantha NULL NULL NULL
Expected Result:
Doctor Professor Singer Actor
-------------------------------------------
Jenny Ashley Meera Jane
Samantha Christeen Priya Julia
NULL Ketty NULL Maria
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL
NULL NULL NULL NULL