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)
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.