Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 4FBE4632520 for ; Tue, 23 Mar 2010 00:49:40 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 97859-02 for ; Tue, 23 Mar 2010 03:49:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from hogranch.com (hogranch.com [75.101.82.47]) by mail.postgresql.org (Postfix) with ESMTP id 513D463220E for ; Tue, 23 Mar 2010 00:49:29 -0300 (ADT) Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id o2N3nLL12085 for ; Mon, 22 Mar 2010 20:49:21 -0700 Message-ID: <4BA83A3C.5080602@hogranch.com> Date: Mon, 22 Mar 2010 20:49:16 -0700 From: John R Pierce User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: string functions and operators References: <22285.35517.qm@web113713.mail.gq1.yahoo.com> In-Reply-To: <22285.35517.qm@web113713.mail.gq1.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-HawgScanner-Information: Please contact the ISP for more information X-HawgScanner: Found to be clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.149 tagged_above=-10 required=5 tests=AWL=0.450, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/817 X-Sequence-Number: 160810 Neil Stlyz wrote: > 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 silly me says.. SELECT FLOOR(x), x-FLOOR(x) FROM TABLE; at least for numeric values. but, in string space, ummmm... select split_part(x,'.',1), split_part(x,'.',2) from table; or select regexp_replace(x, '\.[0-9]*$',''), regexp_replace(x,'^[0-9]*\.','') from table; or god knows how many others.