Author: Alex Date: To: Hampshire LUG Discussion List Subject: Re: [Hampshire] Help with SQL COUNT() statement.
On 8/22/07, Alex <alextcollins@???> wrote: >
>
>
> On 8/22/07, David Ramsden <david@???> wrote:
> >
> > <snip>
> >
> > SELECT COUNT(accesslog.url) AS requests, COUNT(deniedlog.url) AS denied
> > FROM accesslog, deniedlog;
> >
> > But this gives me:
> >
> > +----------+--------+
> > | requests | denied |
> > +----------+--------+
> > | 117500 | 117500 |
> > +----------+--------+
> > 1 row in set (0.00 sec)
>
>
> On second thoughts, you could also provide the two queries, one of which is an subquery in the outer query's FROM clause. Like this:
SELECT COUNT(al.url) AS requests, dl.denied AS denied
FROM accesslog al, (SELECT COUNT(*) AS denied FROM deniedlog) dl
GROUP BY requests, denied;