Amazon interview question

Tricky SQL questions, looking for solution and not for syntactical error.