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 D2DD8DB0B0 for ; Thu, 27 Oct 2005 18:46:41 -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 48455-08 for ; Thu, 27 Oct 2005 21:46:39 +0000 (GMT) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.192]) by svr1.postgresql.org (Postfix) with ESMTP id 83247DB098 for ; Thu, 27 Oct 2005 18:46:40 -0300 (ADT) Received: by xproxy.gmail.com with SMTP id h26so15729wxd for ; Thu, 27 Oct 2005 14:46:43 -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:content-transfer-encoding:content-disposition:references; b=KlfBedswutV9m8IYMJaiIoRHX5Cr7qJI+D2NxuGlIFxU+7xIFGUWEA6E+SmOC7CKGVj9jMWXcaIf1aUo0sZAJCsPTog2or/WDAZWwsbynd9JfJh/6MOwIiyr2zSjv5QT4cb26Eo8UPW7d6yWyDfixzpIJt89WBfek4RfAndl2+s= Received: by 10.70.12.9 with SMTP id 9mr1292294wxl; Thu, 27 Oct 2005 14:46:43 -0700 (PDT) Received: by 10.70.19.8 with HTTP; Thu, 27 Oct 2005 14:46:43 -0700 (PDT) Message-ID: <9e6d8b530510271446w63c1eb8dp97e7703dde3309a4@mail.gmail.com> Date: Thu, 27 Oct 2005 16:46:43 -0500 From: boinger To: Abhishek Subject: Re: combining records from a single table and presenting them as one record Cc: pgsql-sql@postgresql.org In-Reply-To: <506ca6630510271100y367e1fb2hfb05f5ecaae043a3@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <506ca6630510271100y367e1fb2hfb05f5ecaae043a3@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.438 required=5 tests=[AWL=0.438] X-Spam-Score: 0.438 X-Spam-Level: X-Archive-Number: 200510/378 X-Sequence-Number: 23231 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' ), ( selec= t > digits from TABEL1 where type=3D'b' ), ( select digits from TABEL1 where > 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. But > 'distinct' seems to be too expensive. > > Is there any better way I can do this without compromising the performanc= e ? Just add 'LIMIT 1' to the end of the query.