2

How can i do cumulative sum?

My query is :

select dateb,ricetype,bajet1
from bajet
where ricetype='grand total'

How do i archieve 'New Value'?

expected results

Md. Suman Kabir
  • 4,572
  • 3
  • 25
  • 39
Amirul Fahmi
  • 289
  • 1
  • 3
  • 9

1 Answers1

1

You can do it like below :

set @CumSum := 0;
select dateb, ricetype, bajet1, (@CumSum := @CumSum + bajet1) as New_Value
from bajet where ricetype='grand total';
Md. Suman Kabir
  • 4,572
  • 3
  • 25
  • 39