Oracle 关于number类型转换to_char类型 存在的问题

WBOY
Release: 2016-06-07 16:07:53
Original
1705 people have browsed it

Oracle 关于number类型转换to_char类型 存在的问题

Oracle 关于number类型转换to_char类型 存在的问题

select to_char(0.1) nums from dual;

观察发现如果小数的整数位是0, 转换字符串之后没有了前面的0,如果需要前面的0,则需要一定的规则进行格式化,示例如下

select to_char(0.1,'0.9') nums from dual;

我们把小数换成整数后再看

select to_char(1,'0.9') nums from dual;

整数也会编程double类型

关于to_char(x,y),y的规则有很多,,这里不详解,如果想要整数还是整数,小数还是小数的情况下,可以试试下面的方法,借助replace

参考示例如下:

select unitname,hurk,ldrk,replace(b,':.',':0.') scale,rdate from (select unitname,hurk,ldrk,concat( '1:',round(hurk / ldrk,2)) b,rdate from DYNAMICPEOPLE)

本文永久更新链接地址:

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!