Oracle 10g 浮点格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2127649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 19:51:50  来源:igfitidea点击:

Oracle 10g Float format

sqloracleplsqloracle10g

提问by v14nt0

How can I return from float/decimal value with the following:

如何从浮点/十进制值返回以下内容:

SELECT 210 
  FROM DUAL

...to get:

...要得到:

210.00 

...instead of 210?

...而不是210

Using pl/sql oracle 10g

使用 pl/sql oracle 10g

回答by gregseth

SELECT TO_CHAR(210, '999.99') FROM dual;

More to_char related formats here.

更多与 to_char 相关的格式在这里

回答by OMG Ponies

Use:

用:

SELECT CAST(210 AS NUMBER(3,2))
  FROM DUAL

...to get the value as a numeric data type. TO_CHARwith a filter would work, but returns the output as a string.

...获取作为数字数据类型的值。 TO_CHAR使用过滤器可以工作,但将输出作为字符串返回。

Reference:

参考:

回答by Dave7896

You can use the to_char function passing in an optional format string e.g. to_char(210.00,'000.00') would give the desired result. Do a google search for "number formatting in oracle" and you will find some good examples of format strings.

您可以使用传递可选格式字符串的 to_char 函数,例如 to_char(210.00,'000.00') 将给出所需的结果。用谷歌搜索“oracle 中的数字格式”,你会发现一些格式字符串的好例子。

EditLook for "Number Format Elements" here.

在这里编辑查找“数字格式元素” 。