Pergunta de entrevista da empresa IBM

SQL question and an easy coding question.