X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F00AD474E44 for ; Sat, 1 Mar 2003 01:22:45 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 95992-02 for ; Sat, 1 Mar 2003 01:22:41 -0500 (EST) Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id F0A58474E42 for ; Sat, 1 Mar 2003 01:22:40 -0500 (EST) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id EA3251380B6; Sat, 1 Mar 2003 01:22:39 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 18p0ON-0005DT-00; Sat, 01 Mar 2003 01:22:39 -0500 To: Aaron Chu Cc: pgsql-sql@postgresql.org Subject: Re: Beginner needs help References: <96853212-4AA9-11D7-8F7C-000393017462@mac.com> In-Reply-To: <96853212-4AA9-11D7-8F7C-000393017462@mac.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 01 Mar 2003 01:22:39 -0500 Message-ID: <873cm7mwr4.fsf@stark.dyndns.tv> Lines: 13 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/1 X-Sequence-Number: 12041 Aaron Chu 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