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