BNY Interview Question

SQL query on window function