Вот один лайнер, который делает то, что вы хотите:
filter(lambda x: [x for i in string_list if x in i and x != i] == [], string_list)
Пример:
>>> string_list = ['rest', 'resting', 'look', 'looked', 'it', 'spit']
>>> filter(lambda x: [x for i in string_list if x in i and x != i] == [], string_list)
['resting', 'looked', 'spit']
У вас есть два условия. Существует и не существует, приходят на ум:
select ab.*
from ab
where not exists (select 1
from ab ab2
where ab2.astring = ab.bstring and
ab2.id < ab.id
) and -- no earlier "a"s
exists (select 1
from ab ab2
where ab2.astring = ab.bstring
) -- another "a"