pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCount and list only where count is bigger than 1
4+ messages / 4 participants
[nested] [flat]
* Count and list only where count is bigger than 1
@ 2006-09-19 15:04 Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
2006-09-19 15:09 ` Re: Count and list only where count is bigger than 1 Mezei Zoltán <mezei.zoltan@telefor.hu>
2006-09-19 15:09 ` Re: Count and list only where count is bigger than 1 bnichols@ca.afilias.info
2006-09-19 15:15 ` Re: Count and list only where count is bigger than 1 A. Kretschmer <andreas.kretschmer@schollglas.com>
0 siblings, 3 replies; 4+ messages in thread
From: Ezequias Rodrigues da Rocha @ 2006-09-19 15:04 UTC (permalink / raw)
To: 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 ?
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/
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Count and list only where count is bigger than 1
2006-09-19 15:04 Count and list only where count is bigger than 1 Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
@ 2006-09-19 15:09 ` Mezei Zoltán <mezei.zoltan@telefor.hu>
2 siblings, 0 replies; 4+ messages in thread
From: Mezei Zoltán @ 2006-09-19 15:09 UTC (permalink / raw)
To: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>; +Cc: pgsql-sql
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000099">
Ezequias Rodrigues da Rocha wrote:
<blockquote
cite="mid55c095e90609190804w1eaac2aanc660020995d3710a@mail.gmail.com"
type="cite">SELECT distinct cli.bairro, COUNT( * ) as qtd<br>
FROM base.cliente cli<br>
GROUP BY cli.cidade, cli.bairro<br>
ORDER BY 2<br>
<br>
<span style="font-weight: bold;">I noticed that I cannot use "where
qtd > 1" ok ?</span><br>
<br>
What to do ?<br>
</blockquote>
Google/read tutorial for HAVING. E.g.<br>
<br>
SELECT distinct cli.bairro, COUNT( * ) as qtd<br>
FROM base.cliente cli<br>
GROUP BY cli.cidade, cli.bairro<br>
HAVING COUNT(*) > 1<br>
<br>
Zizi<br>
</body>
</html>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Count and list only where count is bigger than 1
2006-09-19 15:04 Count and list only where count is bigger than 1 Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
@ 2006-09-19 15:09 ` bnichols@ca.afilias.info
2 siblings, 0 replies; 4+ messages in thread
From: bnichols@ca.afilias.info @ 2006-09-19 15:09 UTC (permalink / raw)
To: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>; +Cc: 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;
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Count and list only where count is bigger than 1
2006-09-19 15:04 Count and list only where count is bigger than 1 Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
@ 2006-09-19 15:15 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
2 siblings, 0 replies; 4+ messages in thread
From: A. Kretschmer @ 2006-09-19 15:15 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2006-09-19 15:15 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-09-19 15:04 Count and list only where count is bigger than 1 Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
2006-09-19 15:09 ` Mezei Zoltán <mezei.zoltan@telefor.hu>
2006-09-19 15:09 ` bnichols@ca.afilias.info
2006-09-19 15:15 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox