DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: cumulative aggregation in a query

Threaded View

  1. #3
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Here is an example:
    PHP Code:
    SQLselect from t1 ;

        
    ORD_ID ORD_DATE                ORD_AMT
    ---------- -------------------- ----------
             
    8 15-dec-2004 09:56:48        200
             1 15
    -dec-2004 09:56:58         25
             2 15
    -dec-2004 09:57:30         50
             9 15
    -dec-2004 09:57:39        225
             7 15
    -dec-2004 09:57:48        175
             5 15
    -dec-2004 09:58:03        125
             4 15
    -dec-2004 09:58:25        100
             3 15
    -dec-2004 09:59:32         75
             6 15
    -dec-2004 10:11:24        150

    9 rows selected
    .

    SQLget ana
      1  select ord_date
    ord_idord_amt,
      
    2         sum(ord_amtover (
      
    3         order by ord_id range unbounded precedingcum_sale
      4
    from t1
    SQL
    > /

    ORD_DATE                 ORD_ID    ORD_AMT   CUM_SALE
    -------------------- ---------- ---------- ----------
    15-dec-2004 09:56:58          1         25         25
    15
    -dec-2004 09:57:30          2         50         75
    15
    -dec-2004 09:59:32          3         75        150
    15
    -dec-2004 09:58:25          4        100        250
    15
    -dec-2004 09:58:03          5        125        375
    15
    -dec-2004 10:11:24          6        150        525
    15
    -dec-2004 09:57:48          7        175        700
    15
    -dec-2004 09:56:48          8        200        900
    15
    -dec-2004 09:57:39          9        225       1125

    9 rows selected

    Tamil
    Last edited by tamilselvan; 12-15-2004 at 02:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width