From: Lee Harr <missive@frontiernet.net>
To: pgsql-sql@postgresql.org
Subject: Re: Beginner needs help
Date: Sun, 9 Mar 2003 22:42:12 +0000 (UTC)
Message-ID: <b4gg03$t5p$1@news.hub.org> (raw)
References: <96853212-4AA9-11D7-8F7C-000393017462@mac.com>
<b4dtl8$1ejl$1@news.hub.org>
In article <b4dtl8$1ejl$1@news.hub.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;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: missive@frontiernet.net
Subject: Re: Beginner needs help
In-Reply-To: <b4gg03$t5p$1@news.hub.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox