Monday, October 9th, 2006...8:29 am

Formatting Numbers in Oracle and Postgres

Jump to Comments

When dealing with large numbers in oracle sometimes it can be hard to read the results from a query with no formatting in the results. I know I have misread numbers from a query many times. Well, I finally got around to looking up how to format numbers in oracle. And who knew -- TO_CHAR does it for us.

Example In Oracle:

SELECT to_char(5689731,'$9,999,999.00') AS mysalary FROM DUAL

Jason says this also works in Postgres!
Example in Postgres:

SELECT to_char(5689731, '$9,999,999.00') AS mysalary

returns

$5,689,731.00

1 Comment

  • This works in postgresql too.

    Example:

    SELECT to_char(5689731, '$9,999,999.00') AS mysalary

    returns

    $5,689,731.00

Leave a Reply