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
  • 5,243
  • 5
  • 25
  • 43
Amirul Fahmi
  • 299
  • 2
  • 3
  • 10

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
  • 5,243
  • 5
  • 25
  • 43