OrderBy in SQL Server to put positive values before negative values

后端 未结 1 1753
南方客
南方客 2020-12-19 08:00

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 col

1条回答
  •  不知归路
    2020-12-19 08:08

    Select * from Table
    order by 
    Case when sortcolumn<0 then 1 else 0 end
    ,sortcolumn
    

    0 讨论(0)
提交回复
热议问题