I've got a log table below which has the below data. What I want to get from my query is the latest log entry for each user.
ID UserID LogTimeDate
1 1234 12/12/2010 09:15:00 AM
2 1234 12/12/2010 03:15:00 PM
3 5678 11/12/2010 09:15:00 AM
4 5678 15/12/2010 09:15:00 AM
5 789 09/12/2010 09:15:00 AM
6 789 08/12/2010 09:15:00 AM
The current query I have is:
but the results come out as:Code:select * FROM logtable GROUP BY UserID ORDER BY LogTimeDate DESC;
ID UserID LogTimeDate
1 1234 12/12/2010 09:15:00 AM
3 5678 11/12/2010 09:15:00 AM
6 789 08/12/2010 09:15:00 AM
where as the results should be:
ID UserID LogTimeDate
2 1234 12/12/2010 03:15:00 PM
4 5678 15/12/2010 09:15:00 AM
5 789 09/12/2010 09:15:00 AM
It seems to be the Order By is ignored if a Group By is used. Anyone able to help with a query which will return my desired results?




Reply With Quote