Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I am attempting to sort by multiple columns in SQL, and in different directions. column1 would be sorted descending, and the column2 would be sorted ascending.

How can I able to do it?

1 Answer

0 votes
by (12.7k points)
edited by

You can try the below code:

ORDER BY column1 DESC, column2

This will be sorting everything by column1 (in the descending order) first, and then by column2 (in the ascending order, which will be the default) whenever it is seen that the column1 fields for two or more number rows are equal.

Become a SQL expert with this complete SQL Training Course!

Related questions

0 votes
1 answer
asked Jul 4, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Jul 22, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...