I am trying to run a SQL Query in phpmyadmin that will total multiple rows and insert that total into the cell.
The file is sorted by date and then a few other specifics.
I am just having a hard time finding the syntax for it.
Basically I have one column called ‘Points’ and another called ‘Total_Points’
It needs to look like this:
+--------+--------------+
| Points | Total Points |
+--------+--------------+
| 10 | 10 |
| 10 | 20 |
| 10 | 30 |
| 10 | 40 |
+--------+--------------+
And so on and so on.
It seems like there has to be something out there that would do this and I am just missing it
For a running sum you can use “window functions” like this:
I “aggregated” your
ORDER BYcriteria to be the columnord. You may of course replace it.Besides of this: You did not specify a concrete database vendor. My example runs on PostgreSQL. Other SQL dialects may be a little different.