-1

Is it possible to get sum of all the above rows in each row?

Example:

Rows | Count
 1. | 20
 2. | 30
 3. | 10
 4. | 25

And I want to take the follow result

Rows | TotalCount
  1  | 20    (20)
  2  | 50    (20+30) 
  3  | 60    (20+30+10)
  4  | 85    (20+30+10+25) 
Salman A
  • 262,204
  • 82
  • 430
  • 521
Yannis
  • 9
  • 1

1 Answers1

1

You want a cumulative sum. In standard SQL, you use a window function for this:

select rows, sum(count) over (order by rows)
from t;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786