Good! As you can see, the lowest salary appeared first, and the highest salary last. This ascending order of results is performed in T-SQL by default. If you want to be precise and make things clear, however, you can use the keyword
ASC (short for ascending) after the column name:
ORDER BY TotalSum ASC;
Adding the keyword
ASC will change nothing, but it will show your intentions more clearly to anyone reviewing your code.
We can also reverse the order and make the greatest values appear first:
ORDER BY TotalSum DESC;
As you can see, we've added the
DESC keyword after the column name, which is short for descending order. As a result, the greatest values in the column
TotalSum will appear first.
ORDER BY, it's good practice to specify whether the order is
DESC (even if
ASC is used by SQL Server by default), since it makes the query more readable.