Home > Database > Oracle > How to express an integer with two decimal points in Oracle

How to express an integer with two decimal points in Oracle

下次还敢
Release: 2024-05-07 13:27:16
Original
635 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()

1

<code>TO_CHAR(整数, '999999999999999999.99')</code>

Copy after login
rrree

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

1

<code>SELECT TO_CHAR(123456789, '999999999999999999.99') FROM dual;</code>

Copy after login

1

<code>LPAD(整数, 整数长度 + 2, '0') || '.' || SUBSTR(整数, -2)</code>

Copy after login

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

1

<code>SELECT LPAD(123456789, 11 + 2, '0') || '.' || SUBSTR(123456789, -2) FROM dual;</code>

Copy after login

1

<code>TO_NUMBER(整数 || '00') / 100</code>

Copy after login

Method 4: Use the function ROUND()

1

<code>SELECT TO_NUMBER(123456789 || '00') / 100 FROM dual;</code>

Copy after login

1

<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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template