Amazon interview question

Related to basic sql and python