0

SELECT trim(to_char(123,'9999999999D99'));

123.00 (1 row)

SELECT trim(to_char(00,'9999999999D99'));

.00 (1 row)

I wrote the above query it giving the result as .00 if the amount is 0 (Zeor)? I need the output formate as 0.00. how to do this.

PART -1 Format double precision in PostgreSQL

Community
  • 1
  • 1
ungalnanban
  • 9,539
  • 10
  • 44
  • 55

2 Answers2

1

You need to use the following:

SELECT trim(to_char(00,'9999999990D99'));

The 0 sets a leading zero.

David M
  • 71,481
  • 13
  • 158
  • 186
1

Use a 0 instead of 9 of:

SELECT trim(to_char(00,'999999990D99'));
Frank Heikens
  • 117,544
  • 24
  • 142
  • 135