John,
Don't tell me I asked you to do a SUM() without a GROUP BY clause!!!??? Someone pass
me a hammer!
- guess I was so focused on getting around that incompatible pair of GROUP BYs in the
first attempt. It is so
much easier when I can 'play' with the data in MySQL-Front to 'debug'!
Rather th
DL,
I ran the query exactly as you had sent it and ran
into the same error where it talked about mixing
counts without a group clause. So, I added a quick
"group by clientname" and ran it again
One word "PERFECTION".
I can't thank you enough. This is now a blistering
fast query that pro
John,
> > I'm gonna go out on a limb and guess that I'm missing
> > something obvious (and easy) because this sure seems
> > like it should be able to be done.
> >
> > Here's the issue: I need to pull the client name and
> > ID out of one table and then, count the records in a
> > different table
]>
>Sent: Thursday, February 14, 2002 9:36 AM
>Subject: Re: [PHP-DB] counting multiple columns based
on different
>values
>
>
>> This should do the trick (untested):
>>
>> SELECT ClientName, Count(*) FROM Clients LEFT JOIN
Ratings ON
>Clients.ID =
>>
Message -
From: "Peter Vervoorn" <[EMAIL PROTECTED]>
To: "php-db list" <[EMAIL PROTECTED]>
Sent: Thursday, February 14, 2002 9:36 AM
Subject: Re: [PHP-DB] counting multiple columns based on different values
> This should do the trick (untested):
>
>
John,
> I'm gonna go out on a limb and guess that I'm missing
> something obvious (and easy) because this sure seems
> like it should be able to be done.
>
> Here's the issue: I need to pull the client name and
> ID out of one table and then, count the records in a
> different table (called ratin
This should do the trick (untested):
SELECT ClientName, Count(*) FROM Clients LEFT JOIN Ratings ON Clients.ID =
Ratings.ClientID
GROUP BY ClientName
HAVING Ratings.Status = 2 OR Ratings.Status = 3
regards,
Peter
Software Engineer / Trainer
Vervoorn IT
- Original Message -
From: "John H
be a better way but it
doesn't.
Jason Cox
- Original Message -
From: "John Hawkins" <[EMAIL PROTECTED]>
To: "Jason Cox" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, February 13, 2002 9:08 PM
Subject: Re: [PHP-DB] counting multiple
Oops. I spoke too soon.
This didn't quite get it. My results came back with
column 3 and 4 having the exact same number in them
for each record rather than column 3 having the count
of status 3's and column 4 having a count of the
status 4's.
I've tried messing with the left join syntax trying t
All is right in the world! This worked like a charm!
Thank you So much!
John
--- Jason Cox <[EMAIL PROTECTED]> wrote:
> Perhaps the world is just a little more perfect
> today...
>
> Try this:
>
> SELECT
>
clients.clientname,clients.ID,count(ratings2.clientID),count(ratings2.client
> ID) from
Perhaps the world is just a little more perfect today...
Try this:
SELECT
clients.clientname,clients.ID,count(ratings2.clientID),count(ratings2.client
ID) from clients LEFT JOIN ratings as ratings2 on (clients.ID =
ratings2.clientID) LEFT JOIN ratings as ratings3 on (clients.ID =
ratings3.client
11 matches
Mail list logo