Re: Beginner needs help

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Aaron Chu <astrate(at)mac(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Beginner needs help
Date: 2003-03-01 06:22:39
Message-ID: 873cm7mwr4.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Aaron Chu <astrate(at)mac(dot)com> writes:

> 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 FROM table GROUP BY surname HAVING count(*) > 1

More generally, read up on GROUP BY.

--
greg

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Victor Yegorov 2003-03-01 08:37:30 Re: use of geometric types in select ?
Previous Message Stephan Szabo 2003-03-01 02:00:05 Re: Executing SQL commands via triggers without the use of