Amazon interview question

SQL query - test - with joins and complex logics.