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

Home -> Community -> Usenet -> c.d.o.server -> Re: Cummulation ?

Re: Cummulation ?

From: Chris Colclough <chris.colclough_at_jhuapl.edu.nospam>
Date: Tue, 09 Mar 1999 14:39:23 -0500
Message-ID: <36E578EB.DE493E69@jhuapl.edu.nospam>


Using a table named tmpa with the following values:

K VAL
- ----------

A          1
B          2
C          3
D         10
E         20

Use the following query:

  select b.key, sum(a.val)
  from tmpa a, tmpa b
  where a.key <= b.key
  group by b.key

to produce:

K SUM(A.VAL)
- ----------

A          1
B          3
C          6
D         16
E         36

hth
Chris

Nicolas Bronke wrote:

> Is it possible to create a sql statement, to cummulate a column?
>
> E.g.
>
> Table has following entries:
>
> A 1000
> B 2000
> C 3000
>
> The result of the sql should be
>
> A 1000
> B 3000
> C 6000
>
> --
> Viele Grüße
> Nicolas Bronke
Received on Tue Mar 09 1999 - 13:39:23 CST

Original text of this message

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