Допустим, у меня есть следующая таблица
a b c
-----------
1 1 5
1 2 3
4 1 2
1 2 4
4 2 10
И я хочу удалить все строки, в которых ни одна из первых n строк не имеет такого же значения в a и b, как эта строка.
Так, например, результирующие таблицы для различных n будут
n = 1
a b c
-----------
1 1 5
// No row other than the first has a 1 in a, and a 1 in b
n = 2
a b c
-----------
1 1 5
1 2 3
1 2 4
// The fourth row has the same values in a and b as the second, so it is not deleted. The first 2 rows of course match themselves so are not deleted
n = 3
a b c
-----------
1 1 5
1 2 3
4 1 2
1 2 4
// The fourth row has the same values in a and b as the second, so it is not deleted. The first 3 rows of course match themselves so are not deleted
n = 4
a b c
-----------
1 1 5
1 2 3
4 1 2
1 2 4
// The first 4 rows of course match themselves so are not deleted. The fifth row does not have the same value in both a and b as any of the first 4 rows, so is deleted.
Я пытался выяснить, как сделать это, используя not in или a not Существует, но так как меня интересуют два столбца, которые соответствуют не только 1 или целой записи, я изо всех сил.