I have group and user data that looks like this:
I need to create a column that indicates whether or not the members of one group are from different companies.
So for Group A, I'd need the new column to indicate the group is mixed because it has a member from Company 1 and a member from Company 2.
Group B, is non-mixed group because all members are from Company 1.
Is this possible?
(SSMS 2016)
CodePudding user response:
You can do something like the following using Window functions
select *,
Iif(Min(membercompany) over(partition by groupname)
=Max(membercompany) over(partition by groupname),'Same','Mixed')
from t