Forgive me if the title (and my SQL knowledge) seems a bit vague but I will try and explain as clearly as I can.
I have a table DVE_GroupMember, in which Person_StaffNumber is a unique identifier for a person. In this table is a column GroupMember_GroupName which contains a group name that a person can be assigned to.
There is also column GroupMember_StartDate which signified when that person was assigned to that GroupMember_GroupName.
A person can have been assigned to various groups over a period of time, so if I run the following SQL, I get multiple results for the various Person_StaffNumber values in the database (where the group name contains ‘muster’)
select *
from DVE_GroupMember
where GroupMember_GroupName like 'muster%'
What I am trying to do, is select the most recent GroupMember_GroupName that each person has been assigned to.
I have tried the following syntax but it is generating the error ‘incorrect syntax near ‘)’
select *
from DVE_GroupMember
where GroupMember_GroupName like 'muster%'
and GroupMember_StartDate = (SELECT MAX(GroupMember_StartDate)
Would anyone be able to help me with this?
Thanks
1 Answer