SQL - Union All clarification( Did not understand the question of the assignment)
Hi
I did not understand the meaning of the minus sign before subset A in the last row (ORDER BY -a.emp_no DESC)?
Regards
Smriti
Hi Smriti!
-
ORDER BY a.emp_no DESC;
If you end the relevant query this way, you will obtain an output ordered with the
highest employee number on top, the lowest employee number down the list, and the null values at the end. -
ORDER BY a.emp_no ASC;
This ending of the query will do the opposite - the null values will be on top, and then the employee numbers will grow from the lowest to the highest. -
ORDER BY -a.emp_no DESC;
Using this code, you will first order the employees from the lowest to the highest number, and then leave the null values at the end. -
ORDER BY -a.emp_no ASC;
Following the logic explained so far, this ending would list the null value first, and will then order all employees from the highest to the lowest number.
Hope this helps.
Best,
Tsvetelin