Re: strip zeros from fractional part - Mailing list pgsql-general

From Giovanni M.
Subject Re: strip zeros from fractional part
Date
Msg-id 9216699e0510031236g4d8b82daj2b8651fbac90308a@mail.gmail.com
Whole thread Raw
In response to Re: strip zeros from fractional part  (Tony Wasson <ajwasson@gmail.com>)
Responses Re: strip zeros from fractional part  (Sven Willenberger <sven@dmv.com>)
List pgsql-general
Yes! That did it, thanks for the help

On 10/3/05, Tony Wasson <ajwasson@gmail.com> wrote:
> On 10/3/05, Giovanni M. <drayah@gmail.com> wrote:
> > Round and trunc dont provide the functionality I need.
> >
> > Say for example I have two values in a column of type numeric as follows:
> > 23.455
> > 12.300
> >
> > What I need to happen is stripping the "useless" zeros in the
> > fractional part of numbers so 12.300 would become 12.3 and 23.455
> > would stay the same
> >
> > Round and trunc can´t do this without me first checking if the number
> > can indeed be "rounded" to a number without losing its precise value
>
> As a workaround, you could try using the trim function. You'd need to
> cats your numbers to text strings, but it looks like it will drop
> useless 0's for you.
>
> test=# SELECT trim(trailing 0 FROM '12.300'::TEXT)::NUMERIC;
>  rtrim
> -------
>   12.3
> (1 row)
>


--
A World of KEIGI
http://keigi.blogspot.com

pgsql-general by date:

Previous
From: Fernando Grijalba
Date:
Subject: Re: Help with inventory control - Thank You!
Next
From: Ben
Date:
Subject: int values from PQExecParams in binary result mode