Order by x then order by y column in SQL Server

后端 未结 4 1129
忘掉有多难
忘掉有多难 2021-01-19 05:11

Consider a table like

   debit    credit  code
-----------------------------
    0       10      5
    5       0       3
    0       11      2
    0       15         


        
4条回答
  •  一生所求
    2021-01-19 06:18

    Please use below one in order by clause you will get the output that you are looking for

      order by cast(cast(code as varchar(50)) 
                                  + cast(debit as varchar(2)+ cast(credit as varchar(2) as int)
    

提交回复
热议问题