En MySQL, el enfoque más eficiente es usar variables:
select e.*,
(@s := if(@id = e.id, @s + salary,
if(@id := e.id, salary, salary)
)
) as running_salary
from (select e.*
from employee e
order by e.id, e.month
) e cross join
(select @id := -1, @s := 0) params;
También puede hacer esto con una subconsulta correlacionada:
select e.*,
(select sum(e2.salary)
from employee e2
where e2.id = e.id and e2.month <= e.month
) as running_salary
from employee e;