我用存储过程计算一个字段的值,结果出来的结果是以0.05单位保存的,搞不懂是怎么回事?
比如,结果为502.869, 它会保存为 502.90
478.405 会保存为478.45,总之所有的结果都是以 .50,.60 或.85,.35 等等以0.05为进制的结果
这是怎么回事啊
我的字段就是 numeric 类型 2位小数的啊
比如,结果为502.869, 它会保存为 502.90
478.405 会保存为478.45,总之所有的结果都是以 .50,.60 或.85,.35 等等以0.05为进制的结果
这是怎么回事啊
我的字段就是 numeric 类型 2位小数的啊
CREATE proc gedeshui
AS
begin
declare @js numeric
update gzk
--js=yfgz_js+yj_lr-bj_js-ybjf_kk-grjf_kk-njgrjf_kk-gz_jt-fg_jt
set @js=yfgz_js+yj_lr-bj_js-ybjf_kk-grjf_kk-njgrjf_kk-gz_jt-fg_jt,
gds_js=(@js-
case when @js<=2000 then
@js
when @js>2000 then
2000
end
)*
case when @js<=2000 then
0
when @js>2000 and @js<=2500 then
0.05
when @js>2500 and @js<=4000 then
0.1
when @js>4000 and @js<=7000 then
0.15
when @js>7000 then
0.2
end
-
case when @js<=2000 then
0
when @js>2000 and @js<=2500 then
0
when @js>2500 and @js<=4000 then
25
when @js>4000 and @js<=7000 then
125
when @js>7000 then
375
end
end
GO
就应该这样呀,两位就是四舍五入呀。
select cast(502.869 as decimal(18,2))
--->declare @js numeric (28,2)