Resolved: Is the minus sign to keep null values of the emp_no at the bottom?
I tried to remove the minus sign and played with order ASC and DESC and realized that since we are ordering by emp_no if we used ASC normally we will have the records starting with NULL values and if we used DESC it will not give us the right order. so the minus sign is to have ascending order but starting with employee number that is NOT NULL and keep the null values at the bottom.
Is that correct?
Thanks for reaching out.
The cases are:
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.
So, you are right, if you ask for the 3) case.
Hope this helps.