Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

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



Ezequias Rodrigues da Rocha wrote:
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 ?
Google/read tutorial for HAVING. E.g.

SELECT distinct cli.bairro, COUNT( * ) as qtd
FROM base.cliente cli
GROUP BY cli.cidade, cli.bairro
HAVING COUNT(*) > 1

Zizi


Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group