Re: SQLPlus: How to do Running Totals?
From: Roy Johnson <rjohnson_at_shell.com>
Date: Tue, 13 Jul 1993 21:33:31 GMT
Message-ID: <RJOHNSON.93Jul13153331_at_conus.shell.com>
Date: Tue, 13 Jul 1993 21:33:31 GMT
Message-ID: <RJOHNSON.93Jul13153331_at_conus.shell.com>
fgreene_at_hayes.com writes:
SELECT A.FIELDA, SUM(B.FIELDA)
FROM TABLE_ONE A, TABLE_ONE B
WHERE B.FIELDA <= A.FIELDA
GROUP BY A.FIELDA
Oddly, this doesn't seem to work right for me.
SQL> select * from test;
VAL
3 4 1 1 5 5 1 2
8 rows selected.
SQL> select a.val, sum(b.val)
2 from test a, test b
3 where b.val <= a.val
4 group by a.val;
VAL SUM(B.VAL)
------ ----------
1 9 2 5 3 8 4 12 5 44
The middle 3 values are right, but what happened to 1 and 5?
-- -------- Roy Johnson ---- rjohnson_at_shell.com ---- Speaking for myself -------- "When the only tool you have is Perl, the whole | "Hooray for snakes!" world begins to look like your oyster." -- Me | -- The Simpsons (29 Apr 93)Received on Tue Jul 13 1993 - 23:33:31 CEST