世界杯红牌 / 2026-07-22 04:20:18

CREATE FUNCTION [dbo].[GetWeight]

(

@Value decimal(18,3)--重量/体积重

)

returns decimal(18,1)

as

begin

--顺丰重量/体积重以0.5kg为单位向上取值(小数点后两位4舍5入)

declare @Weight decimal(18,3)

select @Weight=

case when @Value<=1 then 1

when @Value>1 and @Value%1>=0 and @Value%1<0.05 then @Value

when @Value>1 and @Value%1>=0.05 and @Value%1<0.55 then FLOOR(@Value)+0.5

when @Value>1 and @Value%1>=0.55 then FLOOR(@Value)+1

end

return @Weight

end

GO

--floor(value)函数返回小于或等于指定值(value)的最小整数

select FLOOR('10.2')--10 向下取整

select FLOOR('10.6')--10

--ceiling(value)函数返回大于或等于指定值(value)的最小整数

select ceiling('10.2')--11 向上取整

select ceiling('10.6')--11

--round()函数遵循四舍五入原则,用于把数值字段舍入为指定的小数位数

DECLARE @Result decimal(18,3)

EXEC @Result= GetWeight '1.09958'

PRINT '函数的结果是:'+CONVERT(varchar(20),@Result)

人各有命,上天注定,有人天生为王,有人落草为寇。脚下的路,如果不是你自己的选择,那么旅程的终点在哪,也没人知道。你会走到哪,会遇到谁,都不一定。

暗黑3彩虹地精刷新规律与寻找技巧
鲨鱼保护日︱关于“海中霸主”,你需要知道这些