Pergunta de entrevista da empresa Amazon

SQL query - test - with joins and complex logics.