I have a table that has historical user records. This is imported. It contains a columns as follows:
RecordId, UserId, AnotherId, LastName, FirstName, AcctType, etc...., ChangeDate
RecordIdis the primary key
I need to get the most recent record for each UserId. I need the entire record. There may be multiple records for a given UserId. In those cases the most recent record will be determined by the most recent ChangeDate.
Some records may not have a UserId (i.e. be null for that column). I do not want to include those records.
I know this is a correlated subquery, but am not so great at writing them - it would be a lot faster if someone could help.
WHERE UserTable.RecordId = ...