So you want to group by the customer, but only show those gorupings with
a count > 5.
That means you want to apply your restriction after the GROUP BY.  Thus,
the clause goes into the HAVING area.
Try:

Select count(*), cust.id
from cust
where cust.time > UNIX_TIMESTAMP(DATE_SUB(NOW(),interval 1 HOUR))
Group by cust.id
HAVING count(cust.id) > 5;

> -----Original Message-----
> From: Jeff McKeon [mailto:[EMAIL PROTECTED] 
> Sent: Monday, August 04, 2003 11:44 AM
> To: [EMAIL PROTECTED]
> Subject: Query Help
> 
> 
> I have a table that records connections from customers to our 
> server. When there is a software problem with our customer's 
> that have older versions of our software, it will dial our 
> server constantly over and over again. 
> 
> I want to be able to detect this by having a query that does 
> something like this.. (I know this where clause won't really work)
> 
> Select count(cust.id)
> from cust
> where cust.time > UNIX_TIMESTAMP(DATE_SUB(NOW(),interval 1 HOUR)) &&
> count(cust.id) > 5
> Group by cust.id;
> 
> Is there a way to do this with one query?
> 
> Thanks,
> 
> Jeff
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
> http://lists.mysql.com/mysql?> [EMAIL PROTECTED]
> 
> 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to