Reputation: 100
I tried using order by clause to sort and re-sort the data on the same column. My query was:
SELECT * FROM Customers ORDER BY Country ASC, Country DESC;
The result is surprising. It sorts the Country
Column in Ascending Order only.
According to my knowledge, the Country
Column should have been sorted in an Ascending order first, then in a Descending order.
Why did SQL skip the next part of the query?
Upvotes: 3
Views: 3444
Reputation: 726479
When you specify multiple items in ORDER BY
clause, the ordering is determined as follows:
Resolving ties using the same column, regardless of the direction, wouldn't change the ordering, because the values in the column are the same within the tied group.
Upvotes: 7