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 decimals, processing with char type loses 0 of the preceding decimal point
For example, 0.2 becomes. 2
2. Workaround: (1) format the digital display with the TO_CHAR function
Select To_char (0.338, ' fm9999999990.00 ') from dual;
Results: 0.34
The focus here is to see the fm9999999999.99, which means that the integer part is up to 10 bits, the fractional part is 2 bits, and the FM indicates that the space before the transpose string is removed, and there are spaces before the fm,0.34. (2) If the Decode function is less than 1, the first digit must be '. ', then judge whether the first is '. ', then add ' 0 ' to the front to sql> Select Decode (substr (num,1,1), '. ', ' 0 ' | | Num,num) from T1_number DECODE (SUBSTR (num,1,1), '. ', ' 0 ' | | Num,num)

Oracle 0 missing points before the decimal point

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.