View Single Post
  #3 (permalink)  
Old Apr 26th, 2006, 20:57
roleary roleary is offline
New Member
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Cant figure out the query

thanks for the reply, but its not that simple (if it was, i wouldn't have posted

the problem with the query that you provided is that, since i'm using a datetime field, every single entry is unique. so if i have 1 user browse the system and go through 5 pages, i'll just see that user name 5 times (since each datetime is unique).

i actually got this problem solved over at the devshed forums. here was the final solution:

SELECT TOP 5
L1.yourdate,
CONCAT(firstname lastname) AS name
L1.page
FROM
user
INNER JOIN log AS L1
ON user.uid=L1.uid
INNER JOIN log AS L2
ON L1.uid=L2.uid
GROUP BY
L1.yourdate,
name,
L1.page
HAVING L1.yourdate=MAX(L2.yourdate)
ORDER BY L1.yourdate DESC
Reply With Quote