Pergunta de entrevista da empresa Amazon

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