Answer the question
In order to leave comments, you need to log in
How to format the result so that it is without non-significant zeros?
There is a table newtable with one column c1 type numeric (20,6)
I need to return the result formatted as follows - instead of 0 there is a space, the rest of the numbers are rounded to hundredths, insignificant zeros are removed.
While there is such a request
select
case
when c1 = 0 then ''
else c1::numeric(20,2)::text
end result
from newtable
select
case
when c1 = 0 then ''
else trim(trailing '.00' from c1::numeric(16,2)::text)
end result
from newtable
Answer the question
In order to leave comments, you need to log in
There is such an option. but it looks pretty creepy
select
case
when c1 = 0 then ''
else rtrim(rtrim(c1::numeric(16,2)::text,'0'),'.')
end result
from newtable
You can also do this:
select
case
when c1 = 0 then ''
else rtrim(to_char (c1, 'FM9999999999999999D99'), '.')
end result
from newtable
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question