Received: from news.tht.net (news.hub.org [216.126.91.242] (may be forged)) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1JE0pE52402 for ; Tue, 19 Feb 2002 09:00:51 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id g1JDrKx37790 for pgsql-sql@postgresql.org; Tue, 19 Feb 2002 08:53:20 -0500 (EST) (envelope-from news) From: "D'laila Pereira" X-Newsgroups: comp.databases.postgresql.sql Subject: SQL query (general) Lines: 30 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Message-ID: Date: Tue, 19 Feb 2002 07:57:49 -0600 X-Complaints-To: abuse@uiuc.edu Organization: University of Illinois at Urbana-Champaign To: pgsql-sql@postgresql.org X-Archive-Number: 200202/284 X-Sequence-Number: 6707 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.