Q&A for anime and manga fans
declare @T table ( c1 int, c2 int ) insert into @T values (100, 1), (100, 1), (101, 2), (101, 3), (102, 4), (102, 5), (103, 6), (104, 7), (104, 7) ;with C as ( select *, count(*) over(partition by C1, C2) as D1, count(*) over(partition by C1) as D2 from @T ) select * from C where D1 = 1 and D2 = 2