Re: Inaccurate results

From: greg(at)turnstep(dot)com
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Inaccurate results
Date: 2003-02-07 19:16:37
Message-ID: 987d1f42f68fc193155c71d4dfe1eb2c@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[simplified]
> select count(distinct(full_phone),state
> from lists group by state
> having count(*) > 250000
> ...
> 199121 UT ***
> ...
> Why would these ( *** ) have showed up in the list?

You are grouping on the *distinct* phones, but running
the HAVING filter on the total counts. Utah has over
250,000 phones, but only 199,121 distinct ones.
In other words, your HAVING clause needs to match your
initial COUNT clause:

having count(distinct(full_phone)

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200302071417

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE+RAbLvJuQZxSWSsgRAv8hAKD57KIzlbu3WT7VaWAkwA+W8Y/siACfcKJ5
PnJXEfSM2I3GvJ7Dg9I7sO0=
=VXd4
-----END PGP SIGNATURE-----

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andrew McMillan 2003-02-08 08:35:39 Re:
Previous Message Chad Thompson 2003-02-07 19:11:41 Re: