declare @Table1 TABLE
(Groups varchar(2), Owner varchar(3), Type varchar(6))
;
INSERT INTO @Table1
(Groups, Owner, Type)
VALUES
('G1', 'M1', 'Member'),
('G1', 'OW1', 'Owner'),
('G2', 'OW1', 'Owner'),
('G3', 'OW1', 'Owner'),
('G3', 'OW2', 'Owner'),
('G4', 'M2', 'Member'),
('G4', 'OW2', 'Owner')
;
;WITH CTE AS (
Select T.Groups,T.Type,T.Owner from (
select Groups, Owner, Type,ROW_NUMBER()OVER(PARTITION BY Groups ORDER BY Type)RN from @Table1
)T WHERE T.RN = 1 AND T.Type <> 'member')
Select * from @Table1 T WHERE EXISTS (Select 1 from CTE WHERE Groups = T.Groups)
感謝@Gordon Linoff – kombsh