Given the following ADuser table:
AD Group UserID
Group1 User1
Group2 User2
Group3 User1
Group3 User3
and Group_Access table:
AD Group Org Codes
Group1 M500_ABC|1098|123_KL|Z45557|f908L_P|234G|
Group2 123_KL|Z45557|f908L_P|
Group3 12345|
how do i consolidate them into a view so that we end up with something like this, where the orgcodes are combined under 1 matching userid?
UserID Org Codes
User1 M500_ABC|1098|123_KL|Z45557|f908L_P|234G|12345|
User2 123_KL|Z45557|f908L_P|
User3 12345|
Notice that because User1 belong to mutiple groups, i.e. Group1 and Group3, all org codes in those 2 groups for user1 are consolidated into1 in the final view, appending the additional 12345| org code
What Ive tried so far:
CREATE VIEW UserOrgCodesView
AS SELECT ADuser.UserID, Group_Access.[Org Codes]
FROM ADuser
INNER JOIN Group_Access ON ADuser.[AD Group]=Group_Access.[AD Group];
but this has yielded in the following
UserID Org Codes
User1 M500_ABC|1098|123_KL|Z45557|f908L_P|234G|12345|
User2 123_KL|Z45557|f908L_P|
User1 12345|
User3 12345|