Amazon interview question

Solving SQL white board coding