Leetcode HARD 579 - Cumulative Salary of Employee RANGE vs ROW BETWEEN in SQL - Explained by EDS

Опубликовано: 18 Август 2026
на канале: Everyday Data Science
1,389
40

Question: https://leetcode.com/problems/find-cu...

SQL Schema:
Create table If Not Exists Employee (id int, month int, salary int)
Truncate table Employee
insert into Employee (id, month, salary) values ('1', '1', '20')
insert into Employee (id, month, salary) values ('2', '1', '20')
insert into Employee (id, month, salary) values ('1', '2', '30')
insert into Employee (id, month, salary) values ('2', '2', '30')
insert into Employee (id, month, salary) values ('3', '2', '40')
insert into Employee (id, month, salary) values ('1', '3', '40')
insert into Employee (id, month, salary) values ('3', '3', '60')
insert into Employee (id, month, salary) values ('1', '4', '60')
insert into Employee (id, month, salary) values ('3', '4', '70')
insert into Employee (id, month, salary) values ('1', '7', '90')
insert into Employee (id, month, salary) values ('1', '8', '90')

Pandas Schema:
data = [[1, 1, 20], [2, 1, 20], [1, 2, 30], [2, 2, 30], [3, 2, 40], [1, 3, 40], [3, 3, 60], [1, 4, 60], [3, 4, 70], [1, 7, 90], [1, 8, 90]]
employee = pd.DataFrame(data, columns=['id', 'month', 'salary']).astype({'id':'Int64', 'month':'Int64', 'salary':'Int64'})


#leetcodesolutions #datascience #sql