Last answered:

04 Feb 2022

Posted on:

27 Jan 2022


SQL - Union All clarification( Did not understand the question of the assignment)


I did not understand the meaning of  the minus sign before subset A in the last row (ORDER BY -a.emp_no DESC)?


1 answers ( 0 marked as helpful)
Posted on:

04 Feb 2022


Hi Smriti!

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Submit an answer