Amazon interview question

Database sql queries challenge