--try
--测试环境
declare @t table(flag int ,value decimal(2,1))
insert into @t select 1,1.5
union all select 2,1.6
union all select 3,1.4--查询语句
select flag,
 value=case when flag=1 then CEILING(value)
    when flag=2 then FLOOR(value) 
    when flag=3 then CEILING(value) end
from @t--结果
flag        value 
----------- ----- 
1           2
2           1
3           1(所影响的行数为 3 行)

解决方案 »

  1.   

    --Sorry ,我看错了!应该这样
    select flag,
     value=case when flag=1 then CEILING(value)
        when flag=2 then FLOOR(value) 
        when flag=3 then CEILING(value) end
    from @t--结果
    flag        value 
    ----------- ----- 
    1           2
    2           1
    3           2(所影响的行数为 3 行)
      

  2.   

    CEILING和FLOOR这两个函数什么意思?怎么用啊?
      

  3.   

    --严格一点应该这样--测试环境
    declare @t table(flag int ,value decimal(2,1))
    insert into @t select 1,1.4
    union all select 2,1.7
    union all select 3,1.2
    --查询
    select flag,
    value=case when flag=1 then round(value,0)
       when flag=2 then FLOOR(value) 
        when flag=3 then CEILING(value) end
    from @t
    --结果
    flag        value 
    ----------- ----- 
    1           1.0
    2           1.0
    3           2.0(所影响的行数为 3 行)
      

  4.   

    --flag=1时用CEILING有问题,应该用ROUND
    select flag,
     value=case when flag=1 then ROUND(value)
        when flag=2 then FLOOR(value) 
        when flag=3 then CEILING(value) end
    from @t
      

  5.   

    round 四舍五入函数
    FLOOR 返回小于或等于所给数字表达式的最大整数。
    CEILING 返回大于或等于所给数字表达式的最小整数。
      

  6.   

    总结的好round 四舍五入函数
    FLOOR 返回小于或等于所给数字表达式的最大整数。
    CEILING 返回大于或等于所给数字表达式的最小整数。
    学习了 谢谢..