Advertisement
saiRo199

sql_interview_moving_sum

Jul 2nd, 2023
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.20 KB | Source Code | 0 0
  1. -- moving sum (cumulative sum using analytical function)
  2.  
  3. SELECT
  4. employee_id,
  5. salary,SUM(salary) OVER(partition BY department_id ORDER BY employee_id) AS cume_sum,
  6. department_id
  7. FROM hr.employees;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement