现在有两个带有小数的数字型,A和B
SELECT抽出的时候,FLOOR(A-B)四舍五入了。
这样写也不行FLOOR(CAST(A AS NUMERIC(9,3))-
                  CAST(B AS NUMERIC(11,3))我只是想把计算之后的小数切掉,不进位

解决方案 »

  1.   

    use tempdb
    if object_id('tb') is not null drop table tb
    go
    create table tb([a] float)
    insert into tb
    select 1 union all
    select 1.0 union all
    select 1.2 union all
    select 1.6 union all
    select 1.22 
    go
    select cast(a as int) as a from tb
    /*
    a
    -----------
    1
    1
    1
    1
    1
    */
      

  2.   

    恩。直接cast(数字 as int)
      

  3.   

    declare @A decimal(9,3)
    declare @B decimal(11,3)set @A = 89.087
    set @B = 789.876select cast(@B-@A as int)
    --
    /*700
    */
      

  4.   

    --没问题啊
    select floor(12.956)-floor(1.333)
    select floor(12.956-1.333)
    /*
    ---------------------------------------
    11(1 行受影响)
    ---------------------------------------
    11(1 行受影响)*/
      

  5.   

    select floor(12.956)-floor(1.333)
    select floor(12.956-1.333)
    select cast((12.956-1.333) as int)
    /*
    ---------------------------------------
    11(1 行受影响)
    ---------------------------------------
    11(1 行受影响)---------------------------------------
    11(1 行受影响)*/