SQL query (general)

From: "D'laila Pereira" <dlailap(at)home(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: SQL query (general)
Date: 2002-02-19 13:57:49
Message-ID: eLsc8.20800$tg4.236195@vixen.cso.uiuc.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

i have the following table R
id a1 a2
1 A B
2 A B
3 B C
4 C A
5 B C

and to write q uery thats outputs the following
id a1 a2
1 A B
2 A B
3 B C
5 B C

Is the following query correct?
select *
from (select *
from R
groupby a1) as T1,
(select *
from R
groupby a1) as T2,
where T1.id<>T2.id
AND T1.a1=T2.a1
AND T1.a2=T2.a2;

please correct.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2002-02-19 14:54:57 Re: Transient Disk Usage Higher In 7.2 ?
Previous Message Henshall, Stuart - WCP 2002-02-19 13:05:05 Re: Join Statements