-- Database schema
| Person : name [ TEXT ] primary_key , age [ INT ] , city [ TEXT ] , gender [ TEXT ] , job [ TEXT ] | PersonFriend : name [ TEXT ] PersonFriend.name = Person.name , friend [ TEXT ] PersonFriend.friend = Person.name , year [ INT ] |
-- -- What are the names of every person who has a friend over 40 and under 30?

SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  >  40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  <  30);