Count and list only where count is bigger than 1
Count and list only where count is bigger than 1
От:
"Ezequias Rodrigues da Rocha" <ezequias.rocha@gmail.com>
Дата:
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 ?
Regards ...
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Atenciosamente (Sincerely)
Ezequias Rodrigues da Rocha
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
A pior das democracias ainda é melhor do que a melhor das ditaduras
The worst of democracies is still better than the better of dictatorships
http://ezequiasrocha.blogspot.com/
Re: Count and list only where count is bigger than 1
От:
Mezei Zoltán <mezei.zoltan@telefor.hu>
Дата:
Ezequias Rodrigues da Rocha wrote:SELECT distinct cli.bairro, COUNT( * ) as qtdGoogle/read tutorial for HAVING. E.g.
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 ?
SELECT distinct cli.bairro, COUNT( * ) as qtd
FROM base.cliente cli
GROUP BY cli.cidade, cli.bairro
HAVING COUNT(*) > 1
Zizi
Re: Count and list only where count is bigger than 1
От:
bnichols@ca.afilias.info
Дата:
> 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;
Re: Count and list only where count is bigger than 1
От:
"A. Kretschmer" <andreas.kretschmer@schollglas.com>
Дата:
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