RE: Running Total

"Jeevan Vaikar" <[email protected]> Fri, 7 Mar 2003 18:08:46 +0530
Newsgroups gmane.comp.db.oracle.devel
Message-ID <LYRIS-1796914-902056-2003.03.07-12.37.15--gcdod-oracle#[email protected]>
if you are using Oracle 8i or higher and the values are not in arithmetic
progression you can try using the sql give below:

select a.num1, case when a.num1 is not null then
(select sum(b.num2) from test b
where b.num1 <= a.num1)
end as total
from test a
order by a.num1


Best Regards,

Jeevan Vaikar


                                                                                                                   
                    Chris Sol                                                                                      
                    <chris.sol@gh        To:     "Oracle" <[email protected]>                                    
                    g.org.uk>            cc:                                                                       
                                         Subject:     [oracle] RE: Running Total                                   
                    06/03/2003                                                                                     
                    03:08 PM                                                                                       
                    Please                                                                                         
                    respond to                                                                                     
                    "Oracle"                                                                                       
                                                                                                                   
                                                                                                                   




Hi

This will do it but you need a table with required number of records in it.

select rownum*10100 as result from table where rownum < 5;

> -----Original Message-----
> From:   keyur76 [SMTP:[email protected]]
> Sent:   06 March 2003 05:49
> To:     Oracle
> Subject:     [oracle] Running Total
>
>
>
>
> 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%%.
>
****************************************************************************

The Genesis Housing Group - Email Disclaimer
--------------------------------------------
The information in this email and any attachments is strictly
confidential and may be legally privileged.
It is intended solely for the use of the addressee(s) only. Access to
this email by anyone else is unauthorised.  If you have received this
email in error please notify the sender immediately by return email or
telephone.  Please note that if you are not the intended recipient, you
must not copy, distribute or otherwise act on any part of this email or
it's attachments.
Although we have taken precautions to ensure that this email and
attachments are free from any virus, we would advise you that it is your
responsibility to ensure that this is true when reading or actioning
this email.

---
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].