SQL: Sort same column asc then desc

I have tried using the order by clause to sort and re-sort the data in the same column. My request:

SELECT * FROM Customers ORDER BY Country ASC, Country DESC;

      

The result is amazing. It Country

only sorts the columns in ascending order.

According to my knowledge, the column Country

should be sorted first in ascending order, then in descending order.

Why did SQL skip the next part of the query?

+3


source to share


1 answer


When you list multiple items in a sentence ORDER BY

, the order is determined as follows:

  • Results are sorted using a first-order specification (column name + direction)
  • Any links that remain are resolved using a second-order specification,
  • Any links that remain are resolved using a third-order specification, etc.


Removing relationships that use the same column, regardless of direction, will not change the order because the values ​​in the column are the same in the related group.

+5


source







All Articles