Amazon interview question

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