Amazon interview question

SQL code along with interviewer