JPMorganChase interview question

SQL query based on window functions.