Amazon interview question

SQL window functions, self joins