[thelist] MySQL multiple counts problem / help needed
Paul Cowan
evolt at funkwit.com
Mon Oct 24 15:53:59 CDT 2005
Ian Goodyer wrote:
> I would like to set up a MYSQL query to display the number of guests
> (sub=0), full members (sub=1) and hidden members (sub=2) for each site.
>
> I can show the number of guests like this of course:
>
> SELECT site, sub, COUNT( * ) AS guests
> FROM users
> WHERE sub = 0
> GROUP BY site
What about:
SELECT site, sub, COUNT( * ) AS usercount
FROM users
GROUP BY site, sub
That should give you one row for each 'sub' value, with the
corresponding total next to it.
Cheers,
Paul
More information about the thelist
mailing list