I need some help with a SQL query. I've been trying to find a way to get the desired information but so far nothing seems to work right. I have a table which looks like this:
personId int, selectedValue int, logDate datetime
For each person there can be multiple records in the table. What I'd like to do is get the last selected value for each person in the table. I am able to get the last date a person selected something with this query:
SELECT personId, MAX(logDate) FROM MySelectedValues GROUP BY personId
Unfortunately I've been unable to come up with a query that will also retrieve the selected value. Any help would be much appreciated!