表A:  编号  数量
       1     2
      2     -5
      3     1
      4     -2怎么样使查的结果都是正数
结果: 编号   数量
       1     2
      2     5
      3     1
      4     2

解决方案 »

  1.   

    selec 编号,abs(数量)
    from tb
      

  2.   

    select 编号 , abs(数量)  数量 from a
      

  3.   

    select 
      编号,
      abs(数量)  as 数量
    from tb
      

  4.   


    declare @table table (编号 int,数量 int)
    insert into @table
    select 1,2 union all
    select 2,-5 union all
    select 3,1 union all
    select 4,-2--第一种方法
    select 编号,abs(数量) from @table--第二种方法
    select 编号,replace(数量,'-','') as 数量  from @table