Re: Inaccurate results - Mailing list pgsql-novice

From greg@turnstep.com
Subject Re: Inaccurate results
Date
Msg-id 987d1f42f68fc193155c71d4dfe1eb2c@biglumber.com
Whole thread Raw
In response to Inaccurate results  ("Chad Thompson" <chad@weblinkservices.com>)
List 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@turnstep.com
PGP Key: 0x14964AC8 200302071417

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

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


pgsql-novice by date:

Previous
From: "Chad Thompson"
Date:
Subject: Re:
Next
From: Andrew McMillan
Date:
Subject: Re: