Calculating a Running Total 🧮
SELECT employee_id, salary, SUM(salary) OVER (ORDER BY employee_id) AS running_total FROM employees;
- The SUM() function with the OVER clause adds up salaries in order.
- ORDER BY defines the sequence for the running total.