Amazon Interview Question

Complex SQL query using self join and partition by on a whiteboard