Amazon interview question

It was mostly based on sql, logical thinking.