Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Can rollup help in this situation?

Re: Can rollup help in this situation?

From: Chris \( Val \) <chrisval_at_bigpond.com.au>
Date: Sat, 31 Jul 2004 00:51:35 +1000
Message-ID: <2mv5jdFr2q18U1@uni-berlin.de>

"D. Alvarado" <laredotornado_at_zipmail.com> wrote in message news:9fe1f2ad.0407300445.3caef245_at_posting.google.com...
| Hi,
| I have a table that records number of new registrants in a day.
| Some records may look like
|
| DAY NUM_REGISTRANTS
| --- ---------------
| 1 10
| 2 5
| 3 8
|
| I would like to create a SELECT statement such that I select the
| number of registrants per day, and the total number of registrants up
| to that point. Can I do that with SQL somehow? Ideally, a SELECT of
| the above data would yield
|
| DAY NUM_REGISTRANTS TOTAL_REGISTRANTS
| --- --------------- -----------------
| 1 10 10
| 2 5 15
| 3 8 23
|
| Thanks for any advice, - Dave

You can try something like the following:

SELECT DayCol "DAY", RegCol "NUM_REGISTRANTS", SUM( RegCol ) OVER ( ORDER BY RegCol ) "TOTAL_REGISTRANTS" FROM <YOUR TABLE>
ORDER BY RegCol

       DAY NUM_REGISTRANTS TOTAL_REGISTRANTS

---------- --------------- -----------------
         1               5                 5
         2              10                15
         3              15                30
         4              20                50
         5              25                75

Cheers.
Chris Val Received on Fri Jul 30 2004 - 09:51:35 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US