Oracle 0 missing points before the decimal point

Source: Internet
Author: User

1. The origin of the problem

When the Oracle database field value is less than 1 decimal, processing with the char type loses 0 of the preceding decimal point

For example, 0.35 becomes. 35

2. Solution: Format digital display with To_char function

Select To_char (0.338, ' fm9999999990.00 ') from dual;

Results: 0.34

The focus here is to see fm9999999999.99, which means that the integer part is up to 10 bits, the decimal part is 2 BITS, FM means to remove the front space after the turn string, without adding fm,0.34 before there will be spaces.

Use of 3.with

With TMP1 as (

SELECT 1 as A, 2 as B from DUAL

UNION

SELECT 1 as A, 3 as B from DUAL

UNION

SELECT 1 as A, 4 as B from DUAL

),

TMP2 as (

SELECT 1 as A, 2 as B from DUAL

UNION

SELECT 1 as A, 3 as B from DUAL

UNION

SELECT 2 as A, 4 as B from DUAL

)

SELECT tmp1.*,tmp2.*

From TMP1 JOIN TMP2

On TMP1. A = TMP2. A

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.