BNY interview question

SQL query on window function