Putting it simply, I want the last record from the group, not the default first. Cheers -- Dave
Dave:
I do not think your first query will give you the desired results either. You cannot depend on which page_id you get from group by - this depends on what decision the optimizer is going to make.
Probably the most efficient way to solve the problem is to add a visit_status enum ('First','Middle','Last') column to the table, and then do
select pageid,count(*),visit_status from hits where visit_status in ('First','Last') group by visit_status;
The drawback is that your hit inserts will get a bit more complex.
-- Sasha Pachev Create online surveys at http://www.surveyz.com/
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]