DBAsupport.com Forums - Powered by vBulletin
Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Cumulative addition of column values in SQL

  1. #11
    Join Date
    Nov 2002
    Location
    New Delhi, INDIA
    Posts
    1,796
    I get it, whats the confusion Abhay ??
    Code:
    sys@ACME.WORLD> desc test_serial
     Name                                                  Null?    Type
     ----------------------------------------------------- -------- ------------------------------------
     ID                                                             NUMBER
     ID_DATE                                                        DATE
     TIME_LAPED                                                     NUMBER
    
    sys@ACME.WORLD> insert into test_serial values (1, sysdate,1);
    
    1 row created.
    
    sys@ACME.WORLD> insert into test_serial values (1, sysdate,1);
    
    1 row created.
    
    sys@ACME.WORLD> insert into test_serial values (1, sysdate,1);
    
    1 row created.
    
    sys@ACME.WORLD> select * from test_serial;
    
            ID ID_DATE   TIME_LAPED
    ---------- --------- ----------
             1 20-JUN-03          1
             1 20-JUN-03          1
             1 20-JUN-03          1
    
    sys@ACME.WORLD> SELECT id, id_date, sum(TIME_LAPED) over (partition by id, trunc(id_date) order by id, id_date)
      2  from  test_serial;
    
            ID ID_DATE   SUM(TIME_LAPED)OVER(PARTITIONBYID,TRUNC(ID_DATE)ORDERBYID,ID_DATE)
    ---------- --------- ------------------------------------------------------------------
             1 20-JUN-03                                                                  1
             1 20-JUN-03                                                                  2
             1 20-JUN-03                                                                  3
    Amar
    "There is a difference between knowing the path and walking the path."

    Amar's Blog  Get Firefox!

  2. #12
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    Strange, but I aint getting it.

    PS

    Code:
    us18:dba>select * from Test_Serial;
    
                      ID ID_DATE            TIME_LAPSED
    -------------------- --------- --------------------
                       2 20-JUN-03                    1
                       2 20-JUN-03                    1
                       2 20-JUN-03                    1
    
    
    us18:dba>SELECT Id, id_date, sum(time_lapsed) OVER(PARTITION BY ID,trunc(id_date) order by Id,id_date)from Test_Serial;
    
                      ID ID_DATE   SUM(TIME_LAPSED)OVER(PARTITIONBYID,TRUNC(ID_DATE)ORDERBYID,ID_DATE)
    -------------------- --------- -------------------------------------------------------------------
                       2 20-JUN-03                                                                   3
                       2 20-JUN-03                                                                   3
                       2 20-JUN-03                                                                   3
    I do get with Windowing clause

    Abhay.
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

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