Re: combining records from a single table and presenting them as one record

From: boinger <boinger(at)gmail(dot)com>
To: Abhishek <ajcool(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: combining records from a single table and presenting them as one record
Date: 2005-10-27 21:46:43
Message-ID: 9e6d8b530510271446w63c1eb8dp97e7703dde3309a4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 10/27/05, Abhishek <ajcool(at)gmail(dot)com> wrote:
> I am tryng to write a query which returns me a record like this
<snip>
> I do the query as this:
>
> select callguid , ( select digits from TABEL1 where type='a' ), ( select
> digits from TABEL1 where type='b' ), ( select digits from TABEL1 where
> type='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 expensive.
>
> Is there any better way I can do this without compromising the performance ?

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Bax 2005-10-27 23:37:12 Re: combining records from a single table and presenting
Previous Message lucas 2005-10-27 20:24:52 Referencing