Alex Rivera | Logout

SQL multiple column ordering

Asked 2010-01-12T18:02:09.567
966

How can I sort multiple columns in SQL and in different directions? For instance, 'column1' would be sorted descendingly and 'column2' ascendingly.

Edit
Report

1 Answer

1509
ORDER BY column1 DESC, column2

This sorts everything by column1 (descending) first, and then by column2 (ascending, which is the default) whenever the column1 fields for two or more rows are equal.

answered 2010-01-12T18:03:53.650

Your Answer