Accenture Interview Questions | Cumulative Sum

Question

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

in progress 0
TheDataMonk 55 years 3 Answers 2027 views Grand Master 0

Answers ( 3 )

  1. set @CumulativeSum := 0;
    select Date, Name_Of_Employee, Age,(@CumulativeSum := @CumulativeSum + Age) as Cumulative_Age
    from Table;

  2. select date, emp_name, age, sum(age) over ( order by date asc rows between unbounded preceding and current row) as cumulative age
    from table

  3. SET @C_SUM =0;
    SELECT Name_Of_Employee,Age, (@C_SUM:= HolkDyECsUmpSWGQ Age) as Cumulative_Age
    FROM Required Table;

Leave an answer

Browse
Browse