remove everything before the period

Started by karinos57over 12 years ago3 messagesgeneral
Jump to latest
#1karinos57
karinos57@hotmail.com

Hi,
I am trying to remove everything before the period in other words i only
want to show the values that starts from the period. For instance
897.78 ==> 78
74.25 ==> 25
3657.256 ==> 256

well the code below only shows everything before the period but i want to
show everything after the period

select volume, substring(volume from 1 for position('.' in volume) - 1) as
column
from MyTable ;

--
View this message in context: http://postgresql.1045698.n5.nabble.com/remove-everything-before-the-period-tp5771179.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Giuseppe Broccolo
giuseppe.broccolo@2ndquadrant.it
In reply to: karinos57 (#1)
Re: remove everything before the period

Il 17/09/2013 04:21, karinos57 ha scritto:

Hi,
I am trying to remove everything before the period in other words i only
want to show the values that starts from the period. For instance
897.78 ==> 78
74.25 ==> 25
3657.256 ==> 256

well the code below only shows everything before the period but i want to
show everything after the period

select volume, substring(volume from 1 for position('.' in volume) - 1) as
column
from MyTable ;

Try with: " SELECT volume, substring(volume from position('.' in volume)
+ 1) AS column FROM MyTable; "

Giuseppe.

--
Giuseppe Broccolo - 2ndQuadrant Italy
PostgreSQL Training, Services and Support
giuseppe.broccolo@2ndQuadrant.it | www.2ndQuadrant.it

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Agustin Larreinegabe
alarreine@gmail.com
In reply to: Giuseppe Broccolo (#2)
Re: remove everything before the period

Try with: Select split_part('897.78','.',2)

http://www.postgresql.org/docs/8.4/static/functions-string.html

On Tue, Sep 17, 2013 at 11:33 AM, Giuseppe Broccolo <
giuseppe.broccolo@2ndquadrant.it> wrote:

Il 17/09/2013 04:21, karinos57 ha scritto:

Hi,

I am trying to remove everything before the period in other words i only
want to show the values that starts from the period. For instance
897.78 ==> 78
74.25 ==> 25
3657.256 ==> 256

well the code below only shows everything before the period but i want to
show everything after the period

select volume, substring(volume from 1 for position('.' in volume) - 1) as
column
from MyTable ;

Try with: " SELECT volume, substring(volume from position('.' in volume) +
1) AS column FROM MyTable; "

Giuseppe.

--
Giuseppe Broccolo - 2ndQuadrant Italy
PostgreSQL Training, Services and Support
giuseppe.broccolo@2ndQuadrant.**it | www.2ndQuadrant.it

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/**mailpref/pgsql-general&lt;http://www.postgresql.org/mailpref/pgsql-general&gt;

--
Gracias
-----------------
Agustín Larreinegabe