Oracle retains 2 decimal places

Source: Internet
Author: User

Source: The item will be taken out of the database Amount (unit), the third party needs the amount of units in yuan, here is related to the question of retaining 2 decimal places

First, the format of the function To_char

Here I summarize these several to_char (int, text),to_char (float, text),to_char (numeric, text)

The function of these functions is to put the input type, according to the format template Text processing, return the corresponding format string.

The template for the above function-text:

Template

Describe

9

Indicates that the bit is a number. If there are no digits to the left of the decimal point, fill in a blank; 0 If there are no digits to the right of the decimal point

0

Leading zeros

. ( period )

Decimal point

Example one:

sql>Select to_char (100.2'9099999999.99') from dual; To_char (100.2,--------------  000000100.20

Description:0 fills to the leading 0 location

Example two:

sql>Select to_char (.  2'9999999990.99') from dual; To_char (. 2,'--------------          0.20

Description:. 2 becomes the 0.20 we know

Mastered the template 9,0,. , we can solve the problem of keeping 2 decimal places smoothly.

Oracle retains 2 decimal places

Related Article

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.