有个float字段里面有一些数据70.14
78.02
79.09
.....
怎么只把小数点后2位的大小比较出来 比如说大于0.12的象上面的比较的话就只有 70.14满足这个条件

解决方案 »

  1.   

    declare @n table
    (
    a float
    )
     
     
    insert into @n values(70.14)
    insert into @n values(78.02)
    insert into @n values(79.09)declare @i float
    set @i = 0.12
    select * from @n
    where right(round(a,2),2) > right(@i,2)结果:
    70.14
      

  2.   

    declare @t table(num float)
    insert @t select 70.14 
    insert @t select 78.02 
    insert @t select 79.09 
    insert @t select 10
    select * from @t where cast('0'+rtrim(right(num,len(num)-charindex('.',num)+1))as float)>0.12 and charindex('.',num)>0
    /*num                                                   
    ----------------------------------------------------- 
    70.140000000000001
    */
      

  3.   


    借用楼上测试数据:
    declare @t table(num float)
    insert @t select 70.14 
    insert @t select 78.02 
    insert @t select 79.09 
    insert @t select 10
    select * from @t where num-cast(num as int)>0.12
      

  4.   


    借用楼上测试数据:
    declare @t table(num float)
    insert @t select 70.14 
    insert @t select 78.02 
    insert @t select 79.09 
    insert @t select 10
    select * from @t where num-cast(num as int)>0.12