How to format a number with optional fraction Is it possible to format a number in Postgresql with optional fraction?  Like:

1.0 -&gt; '1'
1.3 -&gt; '1.3'


I looked into to_char, but I don't get much further than '1.' with to_char(1.0, 'FM9D9'). 

Is it possible, and how? I'm using Postgresql 9.5
You can use trim(trailing '.0', x::text)

SELECT trim(trailing '.0' FROM x::text)
FROM (
  VALUES (1.5),(1.0),(1.04),(1.040),(1.9594830000)
) AS t(x);
  rtrim   
----------
 1.5
 1
 1.04
 1.04
 1.959483
(5 rows)