Amazon interview question

Simple sql queries