I am trying to merge rows from a view (VW_Link_Ben_Usr_Grp) that contains duplicate user and group membership combinations into a table (SY_SC_Link_Usr_Grp) with the result of a particular user / group membership combination only occurring once. Below is the merge statement I came up with, but it produces an error saying missing right parenthesis. I tried this same merge “Using” VW_Link_Ben_Usr_Grp instead of the select distinct, but it resulted in a row for every user /group combination including duplicates.
(Select Distinct(SY_SC_User_ID,SY_SC_Group_ID) US_Group,
Group By Distinct(SY_SC_Group_ID,SY_SC_Group_ID)
VLBUG.SY_SC_User_ID = SY_SC_LINK_USER_GRP.SY_SC_User_ID And
VLBUG.SY_SC_Group_ID = SY_SC_LINK_USER_GRP.SY_SC_Group_ID
When Matched Then
Update Set UG_Expires = VLBUG.EE_Expires
When Not Matched Then