X-Original-To: pgsql-sql@postgresql.org Received: from utahisp.com (pop3.utahisp.com [66.239.12.3]) by postgresql.org (Postfix) with ESMTP id A774F476357 for ; Wed, 12 Mar 2003 15:03:45 -0500 (EST) Received: from chad [63.230.8.76] by utahisp.com (SMTPD32-7.14) id A224401D0314; Wed, 12 Mar 2003 13:01:40 -0700 Message-ID: <0c4901c2e8d2$7c8e6c40$32021aac@chad> From: "Chad Thompson" To: "Jules Alberts" , References: <20030312100410.BBFD01CB1A5@koshin.dsl.systemec.nl> Subject: Re: filtering out doubles Date: Wed, 12 Mar 2003 13:03:43 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Declude-Sender: chad@weblinkservices.com [63.230.8.76] X-Note: This E-mail was scanned by Declude JunkMail (www.declude.com) for spam. X-Archive-Number: 200303/303 X-Sequence-Number: 12342 Distinct on is probably your answer. Something like select distinct on(col2) col1,col2,col3 from mytable The traditional disclamer that goes with this is that distinct on is not SQL standard and is therefore not portable. But it works very well HTH Chad ----- Original Message ----- From: "Jules Alberts" To: Sent: Wednesday, March 12, 2003 3:03 AM Subject: [SQL] filtering out doubles > Hello everyone, > > I was wondering how to filter out double values (where "value" spans > two columns COL1 and COL2) with a SELECT statement. If I have this > table: > > COL1 |COL2 |COL3 > ----------------------------- > a |b |some value > a |b |another value > a |c |yet another value > > what would be the select statement to get this result: > > COL1 |COL2 |COL3 > ----------------------------- > a |b |some value > a |c |yet another value > > I was thinking that DISTINCT would do this, but I don't want to loose > COL3. TIA for any tips! > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >