OrderBy in SQL Server to put positive values before negative values
sql, sql-order-by, sql-server
Solution
Select * from Table
order by
Case when sortcolumn<0 then 1 else 0 end
,sortcolumn
Problem
I have table in SQL Server which contains a column of type "int". The column can contain positive as well as negative values. I want to carry out sorting based on this column values such that rows with positive values in this column come before the negative values. Example: ``` Code SortColumn A 1 B 5 C -1 D -3 E 0 F 2 ``` Desired Output: ``` Code SortColumn E 0 A 1 F 2 B 5 C -3 D -1 ```