Re: filtering out doubles with SELECT

From: "Jules Alberts" <jules(dot)alberts(at)arbodienst-limburg(dot)nl>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: filtering out doubles with SELECT
Date: 2003-03-12 11:11:05
Message-ID: 20030312111147.B52B41CB1A5@koshin.dsl.systemec.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> 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

Sorry for answering myself, I already found it:

select * from tbl t1 where not exists (select * from tbl t2 where
t1.COL1=t2.COL1 and t1.COL2=t2.COL2 and t1.oid <> t2.oid)

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Muhammad Shariq Muzaffar 2003-03-12 14:38:44 create function pl/pgsql c langauge
Previous Message Jules Alberts 2003-03-12 10:07:25 filtering out doubles with SELECT