X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id DDF659FB251 for ; Tue, 19 Sep 2006 12:17:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 78547-02-7 for ; Tue, 19 Sep 2006 12:16:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by postgresql.org (Postfix) with ESMTP id AB9209FB281 for ; Tue, 19 Sep 2006 12:15:12 -0300 (ADT) Received: from [194.25.154.138] (helo=webserv.wug.de) by mrelayeu.kundenserver.de (node=mrelayeu1) with ESMTP (Nemesis), id 0MKwpI-1GPhJW1P4o-0004Ng; Tue, 19 Sep 2006 17:15:10 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1GPhJV-0003oc-00 for pgsql-sql@postgresql.org; Tue, 19 Sep 2006 17:15:09 +0200 Date: Tue, 19 Sep 2006 17:15:09 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: Count and list only where count is bigger than 1 Message-ID: <20060919151509.GB14455@a-kretschmer.de> References: <55c095e90609190804w1eaac2aanc660020995d3710a@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55c095e90609190804w1eaac2aanc660020995d3710a@mail.gmail.com> User-Agent: Mutt/1.5.9i X-Provags-ID: kundenserver.de abuse@kundenserver.de login:51ea9561fc3f6d9539a2acd743e4748c X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.466 tagged_above=0 required=5 tests=AWL, SPF_HELO_PASS X-Spam-Level: X-Archive-Number: 200609/129 X-Sequence-Number: 26340 am Tue, dem 19.09.2006, um 12:04:55 -0300 mailte Ezequias Rodrigues da Rocha folgendes: > 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 ? > > What to do ? HAVING. 17:14 < akretschmer> ??having 17:14 < pg_docbot_ads> For information about 'having' see: 17:14 < pg_docbot_ads> http://www.postgresql.org/docs/current/interactive/queries-table-expressions.html#QUERIES-GROUP Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47215, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net