Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Group by question...
Hope this will work...
SELECT SUM(a.amount), b.monthyear
FROM your_table a, your_table b
WHERE MONTHS_BETWEEN(a.monthyear, b.monthyear) <= 0
GROUP BY b.monthyear
Convert monthyear to date if it is VARCHAR2
HTH Alex
kevinmz_at_my-deja.com wrote in message <7kaqtq$i1b$1_at_nnrp1.deja.com>...
>I need my brain unscrambled by some Oracle
>whiz-kids!
>
>I have a table with values:
>
>Amount MonthYear
>------ ---------
>100 Dec-1996
>223 Jan-1997
>123 Jun-1997
>etc...
>
>How do I get a cumulative total for each row that
>includes all the values for the current row and
>all previous rows (sorted by date).
>
>Example:
>Amount MonthYear Cumulative
>------ --------- ----------
>100 Dec-1996 100
>223 Jan-1997 323
>123 Jun-1997 446
>etc.
>
>I have just about scrambled my brains trying to
>figure this one out.
>
>Thanks in advance.
>Kevin.
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Thu Jun 17 1999 - 22:28:25 CDT
![]() |
![]() |