sql order by two columns

Solutions on MaxInterview for sql order by two columns by the best coders in the world

showing results for - "sql order by two columns"
Denny
01 Mar 2016
1The following shows that you can perform order by with more
2than one column.
3'ASC' denotes ascending sort order, but is optional as it is the default sort order.
4'DESC' denotes descending sort order
5
6SELECT Id, CompanyName, City, Country  
7FROM Supplier 
8WHERE Country IN ('USA', 'Japan', 'Germany') 
9ORDER BY Country ASC, CompanyName DESC
Sara
01 Mar 2017
1SELECT * FROM table_name ORDER BY col1 ASC;				-- ASCending is default
2SELECT * FROM table_name ORDER BY col1 DESC;			-- DESCending
3SELECT * FROM table_name ORDER BY col1 DESC, col2;		-- col1 DESC then col2 ASC
Blythe
04 Jan 2021
1Sort by multiple column : ORDER BY column1 DESC, column2
Alya
12 Aug 2018
1ORDER BY column1 DESC, column2
2