--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 行)
--测试环境
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 行)
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 行)
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 行)
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
FLOOR 返回小于或等于所给数字表达式的最大整数。
CEILING 返回大于或等于所给数字表达式的最小整数。
FLOOR 返回小于或等于所给数字表达式的最大整数。
CEILING 返回大于或等于所给数字表达式的最小整数。
学习了 谢谢..