Amazon Interview Question

SQL window functions, self joins