2016年6月

首页2016年6月
18
Jun
0
12
Jun
0

SQL四舍五入的几种情况

                  (case F_DeductType when 0 then --不去零
                    T_SUPPLEMENTWORKER.f_deductfactor * t_supplement.f_factmoney * t_supplementworker.f_moneyfactor / 10000
                  when 1 then  --去零
                    CAST(T_SUPPLEMENTWORKER.f_deductfactor * t_supplement.f_factmoney * t_supplementworker.f_moneyfactor / 10000 AS INT)
                  when 2 then  --加零
                  ( CASE WHEN T_SUPPLEMENTWORKER.f_deductfactor * t_supplement.f_factmoney * t_supplementworker.f_moneyfactor / 10000 >
                     CAST(T_SUPPLEMENTWORKER.f_deductfactor * t_supplement.f_factmoney * t_supplementworker.f_moneyfactor / 10000 AS INT)
                     THEN
                       CAST(T_SUPPLEMENTWORKER.f_deductfactor * t_supplement.f_factmoney * t_supplementworker.f_moneyfactor / 10000 AS INT) + 1
                     ELSE
                       CAST(T_SUPPLEMENTWORKER.f_deductfactor * t_supplement.f_factmoney * t_supplementworker.f_moneyfactor / 10000 AS INT)
                     END    
                  )
                  when 3 then  --四舍五入
                    Round(T_SUPPLEMENTWORKER.f_deductfactor * t_supplement.f_factmoney * t_supplementworker.f_moneyfactor / 10000,0)
                  else 
                    0 
                  end 
                  ) AS F_DEDUCT,