Pergunta de entrevista da empresa Jet

Some fairly simply DB querying question followed with a question on how to do the same thing programatically.