On Mon, Aug 12, 2002 at 12:55:32PM -0400, Cummings, Shawn (GNAPs) wrote:
> If I have 4,000,000 records, and I just want to make sure that the last 100 
> records do not contain a certain value,  ... how can I efficiently 'count' 
> the number of times in the LAST 100 records that a specific condition exists?

If I understand the question correctly, you can try:

    SELECT COUNT(*) AS Frequency,LogIP FROM Log GROUP BY LogID ORDER BY LogID LIMIT 
100;

which will return a tally of the number of times each LogIP occurs.

> As an example,
> 
> mysql> select COUNT(*) from Log WHERE LogIP="10.0.0.22" ORDER BY LogID 
> LIMIT 100;

-- 
Michael Bacarella  | Netgraft Corp
                   | 545 Eighth Ave #401
 Systems Analysis  | New York, NY 10018
Technical Support  | 212 946-1038 | 917 670-6982
 Managed Services  | http://netgraft.com/


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to