Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appending '0' after decimal in Oracle

I want to append trailing '0' to number while performing Select query:

what I want is to select

344.89 as 344.890

123213.45 as 123213.450

1.2 as 1.200

I tried using to_char(col_name,'000000.000') but that resulted in

344.89 => 000344.890

123213.45 => 123213.450

1.2 => 000001.200

there were unwanted '0' appended to the result.

like image 515
Manish Avatar asked Feb 16 '23 10:02

Manish


1 Answers

You are close with the to_char format. Try this:

to_char(col_name,'999999.000')

The 9s represent optional place holders. The 0s represent putting in leading zeros.

like image 76
Gordon Linoff Avatar answered Feb 17 '23 22:02

Gordon Linoff