Re: Count and list only where count is bigger than 1

From: bnichols(at)ca(dot)afilias(dot)info
To: "Ezequias Rodrigues da Rocha" <ezequias(dot)rocha(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Count and list only where count is bigger than 1
Date: 2006-09-19 15:09:46
Message-ID: 1148.207.219.45.39.1158678586.squirrel@look.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> 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;

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message A. Kretschmer 2006-09-19 15:15:09 Re: Count and list only where count is bigger than 1
Previous Message Mezei Zoltán 2006-09-19 15:09:35 Re: Count and list only where count is bigger than 1