Pergunta de entrevista da empresa IBM

Sql related problem which i couldn't solve