9 Replies Latest reply: Dec 28, 2017 12:20 PM by pradosh thakur RSS

    Cumulative sum in right order

    Lauri Lahti

      Hi all

       

      I have table with values LoadID, value, event_order_id and I'm trying to have cumulative sum / loadid in correct order / cirteria as in the example below.

       

      The calculation for the cumulative sum for LoadID 413465 should go like this.

       

      when event_order_id = 1 the sum is value,

      when event_order_id = 2 the sum is value of the id 1 + value of the id 2

      when event_order_id = 3 the sum is value of the id 1 + value of the id 2 + value of the id 3

       

      LoadIDvalueevent_order_idcumulative sum / loadid
      41346511,845111,845
      413465-0,336211,509
      413465-11,50930,000
      4134903,61613,616
      4134908,125211,741
      413490-6,98234,759
      413490-1,14343,616
      413490-3,61650,000
      4135077,85317,853
      4135071,25929,112
      413507-1,25937,853
      4135071,14945,488
      413507-2,36553,123
      413507-3,3406-0,217
      413507-2,2177-2,434
      413507-1,0808-3,514

       

      Is the some kind of aggr / range sum function that I should use or some kind of Do while ... loop