sql hoto select the last 100 rows sql query http://www.sqlcourse.com/index.html Query Sql Database via date Thank you all for your responses. I have been able to resolve the problem myself though. I have not built a stored procdure to do this, I probably should have specified that. I also should have specified that I am running on SQL 2000. So all of the responses that used WITH appear to fail because it is invalid syntax. Now Uri Dimant was the closest to the final solution. But Uri's query was pulling an extra 46 rows, and I am not sure why, because when I compare my query with Uri's they look almost identical. My final query that appears to be working is: SELECT DISTINCT a.UserName , a.DeviceName , a.DateStamp FROM DocLogon a WHERE a.DateStamp = (SELECT MAX(DateStamp) FROM DocLogon c WHERE c.DeviceName = a.DeviceName) AND A.DeviceName <> '' ORDER BY a.DeviceNameThe excluding of blank a.DeviceName only subtracts 3 rows. Okay, I figured out the difference between Uri's response and the query that works is just the DISTINCT. Wish I would have realized that earlier, it would have saved me a couple more hours of trying to figure this out. Once again thatnk you for all of your responses. Home SQL Home SQL Functions SQL Aggregate functions ?Max function Max function Max with group by, order by Max having, where, in Max date Max count, having SQL MAX() on date value SQL MAX() on date value has average rating 7 out of 10. Total 11 users rated. <> Description In this page we are going to discuss the usage of SQL MAX() function on date type of column of a table. Example Sample table : orders