解决 number to char 补零问题

由于字段在DB中number类型 可以保存 int ,float ,double 数据.

当int 类型 时 直接转换 to_char 或者 || 不会出问题.但是当为float 或者 double 时 会出转换问题(0.25 --> .25 类似问题).

此Sql语句

decode(length(REPLACE(to_char(ACTUAL_VALUE),'.','') ),length(ACTUAL_VALUE),to_char(ACTUAL_VALUE),to_char(ACTUAL_VALUE,'FM99999990.9999'))

(即当int to_char,float doubleto_char(ACTUAL_VALUE,'FM99999990.9999'))可以解决此问题.

 

int 时 不变 , double ,float 时 0.25 -->0.25 非.25

此种'FM99999990.9999'规则为:小数点前 10位,小数点后最多4位,多于4位取舍.FM舍去空格.

Oracle number to char 研究

相关文章:

  • 2021-08-08
  • 2022-01-24
  • 2021-12-18
  • 2022-02-06
  • 2021-07-07
  • 2022-01-30
  • 2022-01-22
  • 2021-12-02
猜你喜欢
  • 2022-01-02
  • 2022-12-23
  • 2021-12-06
  • 2021-08-15
  • 2021-07-15
  • 2021-09-24
  • 2021-08-25
相关资源
相似解决方案