string functions and operators

From: Neil Stlyz <neilstylz(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: string functions and operators
Date: 2010-03-23 01:20:57
Message-ID: 22285.35517.qm@web113713.mail.gq1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql

Hello,

I have a dilema and I was hoping someone here may offer guidance or assistance. I bet this is a very simple question for someone out there but I am having problems coming up with a solution. Here it is...

suppose I have a field with the following values:

77.1
77.2
134.1
134.2
134.3
5.1
5.2

I need two seperate SELECT queries. One would return the following values (everything left of the decimal point)

77
77
134
134
5
5

The second query would return all of the values to the right of the decimal point:

1
2
1
2
3
1
2

Now, I have been using the following information (although very Greek) to try to solve this problem:

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

And I have been playing around with the syntax of the following:

            substring('112.5' from '%#"___.#"_' for '#')

but the aforementioned is not quite working out... can someone please show me a string function that will produce the desired results?

Thanks!
~n

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Petru Ghita 2010-03-23 01:50:10 Re: string functions and operators
Previous Message Adrian Klaver 2010-03-23 00:32:45 Re: Create a function that updates the record with and timestamps

Browse pgsql-novice by date

  From Date Subject
Next Message Petru Ghita 2010-03-23 01:50:10 Re: string functions and operators
Previous Message Ryan Garvey 2010-03-22 16:02:12 How do you query all columns and all tables for a specific string

Browse pgsql-sql by date

  From Date Subject
Next Message Petru Ghita 2010-03-23 01:50:10 Re: string functions and operators
Previous Message A. Kretschmer 2010-03-22 15:05:15 Re: ALTER TYPE my_enum AS ENUM ADD ('label10')