AW: Re: Running Total

"loew" <[email protected]> Thu, 6 Mar 2003 12:03:45 +0100
Newsgroups gmane.comp.db.oracle.devel
Message-ID <LYRIS-1796914-900459-2003.03.06-11.02.07--gcdod-oracle#[email protected]>
The follwoing query does exactly what you want:

select num1, SUM(num2) OVER (ORDER BY num1 RANGE UNBOUNDED PRECEDING)
tot from test


Michael

-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] 
Gesendet: Donnerstag, 06. März 2003 11:47
An: Oracle
Betreff: [oracle] Re: Running Total



try something like this

  1* select t1.num1,(select sum(t2.num2) from test t2 where t2.num1 <=
t1.num1) tot from test t1
SQL> /

      NUM1        TOT
---------- ----------
        10        100
        20        300
        30        600

Regards
Chris Farmer



 

                      "keyur76"

                      <keyur76@indiatim        To:       "Oracle"
<[email protected]>                                                
                      es.com>                  cc:

                                               Subject:  [oracle]
Running Total                                                        
                      06/03/2003 05:49

                      Please respond to

                      "Oracle"

 

 








I want to have running values of num2 so that display wud be something
like this


CREATE TABLE TEST (NUM1 NUMBER(2) , NUM2  NUMBER(3));


INSERT INTO TEST (NUM1,NUM2) VALUES (10,100);
INSERT INTO TEST (NUM1,NUM2) VALUES (20,200);
INSERT INTO TEST (NUM1,NUM2) VALUES (30,300);


NUM Tot
-------------
10 100
20 300
30 600


It is to be achieved using a single SELECT statement.


Thanking u in advance.
Keyur.
Get Your Private, Free E-mail from Indiatimes at
http://email.indiatimes.com Buy the best in Movies at
http://www.videos.indiatimes.com Bid for Air Tickets @ Re.1 on Air
Sahara Flights. Just log on to http://airsahara.indiatimes.com and Bid
Now !


---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to %%email.unsub%%.






---
Change your mail options at http://p2p.wrox.com/manager.asp or 
to unsubscribe send a blank email to %%email.unsub%%.


---
Change your mail options at http://p2p.wrox.com/manager.asp or 
to unsubscribe send a blank email to [email protected].