Hello guys,
Another question about running totals.
I run the below query where I want to calculate the running total up to a date where a specific condition is being met i.e. Action = X.
It works up to a point, but when it finds another value (see the list where value is "0") instead of bringing again the same number and continue from that number, it goes to the next one and has added also the 0 filed to the final total. I know it is the sum function but I can't think of a better way to do it.
Any opinion?
Thanks in advance
Another question about running totals.
I run the below query where I want to calculate the running total up to a date where a specific condition is being met i.e. Action = X.
It works up to a point, but when it finds another value (see the list where value is "0") instead of bringing again the same number and continue from that number, it goes to the next one and has added also the 0 filed to the final total. I know it is the sum function but I can't think of a better way to do it.
Any opinion?
Thanks in advance
SQL:
SELECT DATE, PERSON, ACTION
(SELECT Sum(IIf(T1.ACTION="X",1,0)) FROM Results WHERE T1.MDATE >= MDate AND T1.PERSON = PERSON) AS ACTIONS
FROM DB AS T1
ORDER BY DATE, PERSON;
Attachments
Last edited by a moderator: