1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Oracle】1未満の小数が「.1」になる表示の修正

Last updated at Posted at 2023-01-25

Oracleで「0.1」をファイル出力等すると「.1」になるため、これを「0.1」としたい。

整数部3桁、小数点以下2桁

TO_CHAR(数値, 'FM990.99')

FM:以降のスペースを削除
9:数値がなければスペース
0:数値がなければ0
.:その場所に小数点

これだけでは整数の場合、「1.」となるため、更に末尾が小数点なら削除する。

RTRIM(TO_CHAR(数値, 'FM990.99'), '.')
  • TO_CHARだけでできないか?
    →無理そう
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?