Amazon interview question

SQL queries