Please tell me the names of the person who has friends with age above 40 and under age 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 ) 
names of the person who has friends = SELECT name FROM ... JOIN ... ON ...; with age above 40 = WHERE age > 40; under age 30 = WHERE age < 30; INTERSECT used to find persons meeting both conditions.