MySQL order by 0 then largest
mysql, sorting
Solution
Try this `order by` statement:
order by val = 0 desc, val desc
The first part is a boolean that evaluates to "1" when the value is 1 and otherwise 0. The second orders the rest of the values in descending order.
Problem
I am trying to do a mysql sort that displays `0` first and then by the largest number. My current mysql statement returns ``` 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0 ``` But I would like to get this ``` 0, 0, 0, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ``` Is it possible to build a MySQL query that orders an integer from largest to smallest with `0` at the beginning?