OK, here is a problem that has been bugging me for some time.

If I have a table like this, showing 3 visitors to a website and the pages they 
view....

id    visitorID    pageID
1    1                3
2    1                4
3    1                2
4    2                3
5    2                4
6    3                2
7    3                4

so to get the count for each entry page to the site I would do:

SELECT pageid, count(pageID) as 'count' FROM hits GROUP BY visitorid ORDER BY 'count' 
DESC

pageid    count
3            2
2            1

so page 3 has been the first page people visit 2 times and page 2 has been the first 
page once.

BUT how do I get the last page they have visited? a sort of reverse GROUP BY??? Which 
would return...

pageid    count
4            2
2            1

Please Help its driving me nuts :S
--
Dave

Reply via email to