SQL Order By Multiple Columns

  • Home
  • SQL
  • SQL Order By Multiple Columns

SQL Order By Multiple Columns is used to sort record according to multiple columns.

Syntax


SELECT * FROM table_name
WHERE condition 
ORDER BY column_name1 ASC|DESC, column_name2 ASC|DESC, column_name3 ASC|DESC .. . . .  column_nameN ASC|DESC;



StudentID StudentName StudentCity
1 Rahul Chandigarh
2 Karan Mohali
3 Neha Delhi
4 Manpreet Chandigarh
5 Ajay Delhi



SELECT * FROM Student
WHERE 1 ORDER BY StudentCity DESC, StudentName ASC



StudentID StudentName StudentCity
2 Karan Mohali
5 Ajay Delhi
3 Neha Delhi
4 Manpreet Chandigarh
1 Rahul Chandigarh

Back To Top