From: | "SunWuKung" <Balazs(dot)Klein(at)t-online(dot)hu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: chop off non-meaningful digits |
Date: | 2006-11-13 14:07:04 |
Message-ID: | 1163426824.618205.54420@i42g2000cwa.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Yep, I think this is it:
select trim(trailing '0.' from 1.020)
Many thanks.
SWK
"A. Kretschmer" wrote:
> am Mon, dem 13.11.2006, um 5:45:44 -0800 mailte SunWuKung folgendes:
> > What would be the easiest way to get back only the meaningful digits of
> > a numeric value in a pgsql function? eg?
> >
> > 1.002 --> 1.002
> > 1.020 --> 1.02
> > 1.200 --> 1.2
> > 1.000 --> 1
>
> You can use trim for this:
>
> test=*> select 1.020 + 0.01;
> ?column?
> ----------
> 1.030
> (1 row)
>
> test=*> select trim(trailing '0' from 1.020 + 0.01);
> rtrim
> -------
> 1.03
> (1 row)
>
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header)
> GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2006-11-13 15:11:53 | Re: Inserting data in composite types |
Previous Message | Marcus Engene | 2006-11-13 14:06:17 | Re: encoding advice requested |