Re: Beginner needs help

From: Lee Harr <missive(at)frontiernet(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Beginner needs help
Date: 2003-03-09 22:42:12
Message-ID: b4gg03$t5p$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In article <b4dtl8$1ejl$1(at)news(dot)hub(dot)org>, Björn Lundin wrote:
> Aaron Chu wrote:
>
>> Hi,
>>
>> I have a table which has a column of surnames (string) and I would like
>> to know how can I retrieve (SELECT) all the repeated surnames, i.e.
>> more than one person who has the same surname.
>
> select surname, count('a') from table
> group by surname
> having count('a') > 1
> order by surname
>

SELECT DISTINCT surname
FROM table t1, table t2
WHERE t1.surname = t2.surname
AND t1.oid != t2.oid
ORDER BY surname;

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message jack 2003-03-10 00:47:49 Re: pl/pgsql how to return multiple values from a function
Previous Message Neil Conway 2003-03-09 21:20:05 Re: Cursors and backwards scans and SCROLL