0
Write SQL query to sort based on 2 columns
I have to write query in Oracle to sort the result based on count descending and then by manufacturer in ascending order. I tried many ways to write this but I'm getting errors. If anyone can guide me that would be a great help
2 ответов
+ 1
If you sort by 2 parameters one after the other, it gives the same result as sorting by only the last parameter.
+ 1
Given that you are (correctly) counting and grouping in the same query, you just have to ORDER BY COUNT(column_name) DESC, manufacturer ASC.
Note that the ASC clause is not mandatory and can be omitted but in this case gives more readability. 😎