X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id E7B219FB27E for ; Tue, 19 Sep 2006 12:11:43 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 65964-04-4 for ; Tue, 19 Sep 2006 15:10:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.libertyrms.com (vgateway.libertyrms.info [207.219.45.62]) by postgresql.org (Postfix) with ESMTP id 40B369FB2BB for ; Tue, 19 Sep 2006 12:09:47 -0300 (ADT) Received: from vgateway.int.libertyrms.com ([10.1.3.254] helo=look.libertyrms.com) by mail.libertyrms.com with esmtp (Exim 4.22) id 1GPhEI-0001qf-4N; Tue, 19 Sep 2006 11:09:46 -0400 Received: from 207.219.45.39 (SquirrelMail authenticated user bnichols) by look.libertyrms.com with HTTP; Tue, 19 Sep 2006 11:09:46 -0400 (EDT) Message-ID: <1148.207.219.45.39.1158678586.squirrel@look.libertyrms.com> In-Reply-To: <55c095e90609190804w1eaac2aanc660020995d3710a@mail.gmail.com> References: <55c095e90609190804w1eaac2aanc660020995d3710a@mail.gmail.com> Date: Tue, 19 Sep 2006 11:09:46 -0400 (EDT) Subject: Re: Count and list only where count is bigger than 1 From: bnichols@ca.afilias.info To: "Ezequias Rodrigues da Rocha" Cc: pgsql-sql@postgresql.org User-Agent: SquirrelMail/1.4.5 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-SA-Exim-Mail-From: bnichols@ca.afilias.info X-SA-Exim-Scanned: No; SAEximRunCond expanded to false X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.096 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, NO_REAL_NAME X-Spam-Level: * X-Archive-Number: 200609/128 X-Sequence-Number: 26339 > Hi list, > > It is possible to make a count select and only display where count column > is > bigger than 1 ? > > My SQL is like this > > SELECT distinct cli.bairro, COUNT( * ) as qtd > FROM base.cliente cli > GROUP BY cli.cidade, cli.bairro > ORDER BY 2 > > I noticed that I cannot use "where qtd > 1" ok ? SELECT distinct cli.bairro, COUNT( * ) as qtd FROM base.cliente cli GROUP BY cli.cidade, cli.bairro HAVING count(*) > 1;