SQLite Forum

running total
Login

running total

(1) By SHABZO on 2020-09-06 15:42:29 [source]

I need some help regarding a running total.I am using sqlite 3.2 on a windows 7 version. I have a qtydel and a qtyrec column. qtydel - qtyrec gives me a total for a column called RT. How do I get a running total of RT.. I tried using the following: Sum(qtydel) - Sum(qtyrec) + COALESCE(BFD, 0) AS RT, SUM(RT) OVER(ROWS UNBOUNDED PRECEDING) AS NoOfCyl,

(2) By Ryan Smith (cuz) on 2020-09-06 16:22:39 in reply to 1 [link] [source]

It seems you did not quite finish the question, so I'm assuming you are asking how to calculate a running total and showing the SQL you've already tried, but perhaps it doesn't work?

From that assumption I can answer like this:

At a glance, the SQL seems fine - but I'm pretty sure that will not work on SQLite 3.2 - If I recall, Window functions saw the light around 3.28 only.

We are currently on 3.33 - is there a way you can upgrade? Windows 7 should have no trouble with that.
To upgrade simply see the downloads page for sources, and there are even Windows pre-compiled DLL's and Windows-based SQLite3.exe cli that could be used.

Once upgraded, the Window functions (including the one you posted) should work just fine.

If my assumption about the question's meaning is wrong, please post a more clear question and we'll try to help.