Search code examples
mysqlsqldatabaseoracle-databaserdbms

SQL Order by ASC and DESC


The following SQL statement selects all customers from the Customers table, sorted by columns Country and CustomerName , but what confused me the result , since the country result is alright 'cause it's ASC -By default so it started from A-Z , as well as the CustomerName should be ASC , But the result is not ! so it's not ASC , Why ?

enter image description here


Solution

  • Your result are indeed ordered correctly. It orders by Country first, THEN it orders by CustomerName. Within Argentina, your Customers are sorted correctly. Within Brazil, they are sorted correctly.

    If you expected Comercio Miniero to be second in the list, ask yourself how that would impact your Country sort order. The sort order will do all the first column, then within that existing order, it will do the second column you listed.