How many people are in New York City?
select count ( * ) from person where city = "new york city"
How many friends does Bob have?
select count ( * ) from ( select t2.friend from person as t1 join personfriend as t2 on t1.name = t2.name where t1.name = 'Bob' )
What is Bob's friend's name?
select t2.friend from person as t1 join personfriend as t2 on t1.name = t2.name where t1.name = 'Bob'