Home > Database > Oracle > body text

How to express an integer with two decimal points in Oracle

下次还敢
Release: 2024-05-07 13:27:16
Original
544 people have browsed it

There are four ways to complement an integer to two decimal points in Oracle: using the TO_CHAR() function, using the LPAD() and SUBSTR() functions, using the TO_NUMBER() and TRUNC() functions, or using ROUND( ) function.

How to express an integer with two decimal points in Oracle

How to add two decimal points to an integer in Oracle

To add two decimal points to an integer in Oracle , you can use the following methods:

Method 1: Use function TO_CHAR()

<code>TO_CHAR(整数, '999999999999999999.99')</code>
Copy after login
rrree

Method 2: Use function LPAD() and SUBSTR()

<code>SELECT TO_CHAR(123456789, '999999999999999999.99') FROM dual;</code>
Copy after login
<code>LPAD(整数, 整数长度 + 2, '0') || '.' || SUBSTR(整数, -2)</code>
Copy after login

Method 3: Use the functions TO_NUMBER() and TRUNC()

<code>SELECT LPAD(123456789, 11 + 2, '0') || '.' || SUBSTR(123456789, -2) FROM dual;</code>
Copy after login
<code>TO_NUMBER(整数 || '00') / 100</code>
Copy after login

Method 4: Use the function ROUND()

<code>SELECT TO_NUMBER(123456789 || '00') / 100 FROM dual;</code>
Copy after login
<code>ROUND(整数, 2)</code>
Copy after login

The above methods can add two decimal points to the integer . Just choose the method that best suits your needs.

The above is the detailed content of How to express an integer with two decimal points in Oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
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!