Leetcode Window Function Postgresql