Quantiphi Interview Question

Windows function in Sql and puzzle