Reputation: 1419
I have 10 rows with a column 'passion_level' that has both negative and positive values:
-3 5 8 9 -11 0 3 1 10 -8
If I run the query SELECT * FROM table ORDER BY passion_level DESC
I get the numbers ordered as you would expect, from high to low with the negative numbers at the bottom of the list. But how do we get mysql to order a column of signed integers disregarding the sign (treat negative numbers as positive numbers) so we get rows returned in this order:
-11 10 9 8 -8 5 -3 3 1 0
Upvotes: 1
Views: 985
Reputation: 8828
Try and create a new column and use ABS(), then reorder according to the new column desc
SELECT *,ABS(passion_level) as order FROM table ORDER BY ABS(passion_level) DESC
Upvotes: 1