Vinz
Vinz

Reputation: 131

How to convert integer number so that they have n decimal places in PostgreSQL SELECT

How can numbers converted so that they have n decimal places?

I want to convert all numbers of a column so that they have three decimal places. For example the query result should look like this

Amount
3.000
2.511
3.200
...

Upvotes: 0

Views: 612

Answers (1)

Mike Organek
Mike Organek

Reputation: 12494

Please see this page: https://www.postgresql.org/docs/current/functions-formatting.html

select to_char(amount, '999D999') as "Amount"
  from your_table;

Upvotes: 1

Related Questions