Discussion:
cumulative totals
(too old to reply)
m***@gmail.com
2020-01-08 18:36:54 UTC
Permalink
I have a table called "DailyNewAccounts"with the following entries:

CountOfid yyyymmdd
8 2019/11/01
8 2019/11/02
11 2019/11/03
7 2019/11/04

where CountOfid and yyyymmdd are the field names

I am struggling to create a query that will result in:

CountOfid yyyymmdd cumulative
8 2019/11/01 8
8 2019/11/02 16
11 2019/11/03 27
7 2019/11/04 34


The end result is that I need to create a chart for both daily new accounts and cumulative.


Any help much appreciated,

Cheers

James
Ron Weiner
2020-01-08 19:05:16 UTC
Permalink
Post by m***@gmail.com
CountOfid yyyymmdd
8 2019/11/01
8 2019/11/02
11 2019/11/03
7 2019/11/04
where CountOfid and yyyymmdd are the field names
CountOfid yyyymmdd cumulative
8 2019/11/01 8
8 2019/11/02 16
11 2019/11/03 27
7 2019/11/04 34
The end result is that I need to create a chart for both daily new accounts and cumulative.
Any help much appreciated,
Cheers
James
Try:

SELECT DailyNewAccounts.yyyymmdd, DailyNewAccounts.CountOfid,
(Select Sum(CountOfid) From DailyNewAccounts as RT
Where RT.yyyymmdd <=DailyNewAccounts.yyyymmdd) AS cumulative
FROM DailyNewAccounts
ORDER BY DailyNewAccounts.yyyymmdd;

Rdub
James Poole
2020-01-12 18:42:34 UTC
Permalink
Post by Ron Weiner
Post by m***@gmail.com
CountOfid yyyymmdd
8 2019/11/01
8 2019/11/02
11 2019/11/03
7 2019/11/04
where CountOfid and yyyymmdd are the field names
CountOfid yyyymmdd cumulative
8 2019/11/01 8
8 2019/11/02 16
11 2019/11/03 27
7 2019/11/04 34
The end result is that I need to create a chart for both daily new accounts
and cumulative.
Any help much appreciated,
Cheers
James
SELECT DailyNewAccounts.yyyymmdd, DailyNewAccounts.CountOfid,
(Select Sum(CountOfid) From DailyNewAccounts as RT
Where RT.yyyymmdd <=DailyNewAccounts.yyyymmdd) AS cumulative
FROM DailyNewAccounts
ORDER BY DailyNewAccounts.yyyymmdd;
Rdub
Many thanks. I was lost in the world of dsum()

Loading...