Share
Accenture Interview Questions | Cumulative Sum
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
How to get the cumulative sum in a table with Date,Name_Of_Employee, and Age
Required table
Date Name_Of_Employee Age Cumulative_Age
Answers ( 3 )
set @CumulativeSum := 0;
select Date, Name_Of_Employee, Age,(@CumulativeSum := @CumulativeSum + Age) as Cumulative_Age
from Table;
select date, emp_name, age, sum(age) over ( order by date asc rows between unbounded preceding and current row) as cumulative age
from table
SET @C_SUM =0;
SELECT Name_Of_Employee,Age, (@C_SUM:= HolkDyECsUmpSWGQ Age) as Cumulative_Age
FROM Required Table;