X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E0CB0DA8FC for ; Fri, 28 Oct 2005 12:47:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07097-05 for ; Fri, 28 Oct 2005 15:47:13 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.205]) by svr1.postgresql.org (Postfix) with ESMTP id DACEFDA8F8 for ; Fri, 28 Oct 2005 12:47:12 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 71so261157wra for ; Fri, 28 Oct 2005 08:47:12 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=McVZLNRXU5xvq4eHJ/4GU1PFEzvQGOEB6tKyttNoDjaWqU9Z080VW1nCRXE5GRH7wIF3zlfg7sOxSfDExFrq1zngEGuwLatIMaCf/q1BadmntH0Rchg0YWl30dqdGcHXONvQEe82eKeewk6cNenZ2onX7iJkwo/23LG81bjPJF4= Received: by 10.54.76.5 with SMTP id y5mr223078wra; Fri, 28 Oct 2005 08:47:12 -0700 (PDT) Received: by 10.54.99.1 with HTTP; Fri, 28 Oct 2005 08:47:12 -0700 (PDT) Message-ID: <506ca6630510280847m2a875f05y4897cce58e4adf8e@mail.gmail.com> Date: Fri, 28 Oct 2005 11:47:12 -0400 From: Abhishek To: boinger Subject: Re: combining records from a single table and presenting them as one record Cc: pgsql-sql@postgresql.org In-Reply-To: <9e6d8b530510271446w63c1eb8dp97e7703dde3309a4@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3528_16459362.1130514432538" References: <506ca6630510271100y367e1fb2hfb05f5ecaae043a3@mail.gmail.com> <9e6d8b530510271446w63c1eb8dp97e7703dde3309a4@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.001 required=5 tests=[HTML_MESSAGE=0.001] X-Spam-Score: 0.001 X-Spam-Level: X-Archive-Number: 200510/385 X-Sequence-Number: 23238 ------=_Part_3528_16459362.1130514432538 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Using LIMIT 1 does return me a single record but please note that the table can have multiple guids for which I need a unique record with all the digit types combined. Using LIMIT 1 returns me always one record. :-( On 10/27/05, boinger wrote: > > On 10/27/05, Abhishek wrote: > > I am tryng to write a query which returns me a record like this > > > I do the query as this: > > > > select callguid , ( select digits from TABEL1 where type=3D'a' ), ( sel= ect > > digits from TABEL1 where type=3D'b' ), ( select digits from TABEL1 wher= e > > type=3D'c' ) from TABLE1; > > > Note that I get the records which i wanted, but I get them duplicated. > If I > > use 'distinct' keyword I get the desired result with no duplication. Bu= t > > 'distinct' seems to be too expensive. > > > > Is there any better way I can do this without compromising the > performance ? > > Just add 'LIMIT 1' to the end of the query. > -- Abhishek Jain ------=_Part_3528_16459362.1130514432538 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Using LIMIT 1 does return me a single record but please note that the table= can have multiple guids for which I need a unique record with all the digi= t types combined. Using LIMIT 1 returns me always one record. :-(

On 10/27/05, boinger <boinger@gmail.com= > wrote:
On 10/27/05, Abhishek <ajcool@gmail.com> wrote:
> I am = tryng to write a query which returns me a record like this
<snip>
> I do the query as this:
>
> select cal= lguid , ( select digits from TABEL1 where type=3D'a' ), ( select
> di= gits from TABEL1 where type=3D'b' ), ( select digits from TABEL1 where
&= gt; type=3D'c' ) from TABLE1;
<snip>
> Note that I get the records which i wanted, but I = get them duplicated. If I
> use 'distinct' keyword I get the desired = result with no duplication. But
> 'distinct' seems to be too expensiv= e.
>
> Is there any better way I can do this without compromising= the performance ?

Just add 'LIMIT 1' to the end of the query.



--
Abhishek Jain
------=_Part_3528_16459362.1130514432538--