I have an activity log table on a site. There are columns for date/time, userID and IP address for each log-in.
I want to retrieve a list of unique usernames and the most recent IP address they logged in from.
What’s the best way to retrieve this from the table using t-sql on SQL Server?
A portable approach is:
If you have SQL Server 2005+, you can also do: