将字段的值进行一些处理, 字段是decimal类型, 后面有2位小数。 如果后2位小数大于60 ,则减去60,小数前的数字加1
否则不变。
如10.60 ,返回11.0 , 1.89 返回2.29, 3.30 返回还是 3.30
谢谢指教
------解决方案--------------------
- SQL code
declare @input as decimal(10,2)declare @temp as decimal(10,2)declare @temp1 as intset @input=1.89select @temp=(@input-cast(@input as int)),@temp1=cast(@input as int)if @temp>0.60 begin set @[email protected] set @[email protected]+1 endelse begin set @temp=0 set @[email protected]+1 endselect @[email protected]
------解决方案--------------------
declare @n decimal(5,2)
set @n=12.61
select case when right(CONVERT(varchar(8), @n),2)>='6' then @n+0.4 else @n end
---------------------------------------
13.01
(1 行受影响)
------解决方案--------------------
- SQL code
declare @d dec(18,2)set @d=1.89select case when @d*100%100>=60 then @d+0.4 else @d end