Re: A select DISTINCT query?

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: phil(at)pricom(dot)com(dot)au
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: A select DISTINCT query?
Date: 2008-01-27 14:16:30
Message-ID: 479C923E.1030002@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Phil Rhoades wrote:
> People,
>
> I want to select from a table ONLY unique records ie if a column has
> values:
>
> 1
> 2
> 3
> 3
> 4
> 5
>
> I want ONLY these records returned:
>
> 1
> 2
> 4
> 5

SELECT count(*) as cnt,a,b,c FORM yourtable
GROUP BY a,b,c
HAVING cnt=1

should do.

Regards
Tino

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Phil Rhoades 2008-01-27 16:21:28 Re: A select DISTINCT query?
Previous Message Pavel Stehule 2008-01-27 14:10:17 Re: A select DISTINCT query?