Intellipaat Back

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

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

How can I do this?

1 Answer

0 votes
by (40.7k points)

Try this code:

ORDER BY column 1 DESC, column 2

The above code sorts everything by column 1 (in descending order) first, and then by column 2 (in ascending order, which will be done by default), it happens whenever the column 1 fields for two or more rows are equal.

Related questions

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

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...