ow and all following rows can be done with the use of UNBOUNDED FOLLOWING: SELECT name, test, score, SUM(score) OVER (ORDER BY score RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS total_score FROM student_test ORDER BY score; +---------+--------+-------+-------------+ | name | test | score | total_score | +---------+--------+-------+-------------+ | Esben | Tuning | 31 | 453 | | Esben | SQL | 43 | 422 | | Kaolin | SQL | 56 | 379 | | Chun | Tuning | 73 | 323 | | Chun | SQL | 75 | 250 | | Tatiana | SQL | 87 | 175 | | Kaolin | Tuning | 88 | 88 | +---------+--------+-------+-------------+ It's possible to specify a number of rows, rather than the entire unbounded following or preceding set. The following example takes the current row, as well as the previous row: SELECT name, test, score, SUM(score) OVER (ORDER BY score ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS total_score FROM student_test ORDER BY score; +---------+--------+-------+-------------+ | name | test | score | total_score | +---------+--------+-------+-------------+ | Esben | Tuning | 31 | 31 | | Esben | SQL | 43 | 74 | | Kaolin | SQL | 56 | 99 | | Chun | Tuning | 73 | 129 | | Chun | SQL | 75 | 148 | | Tatiana | SQL | 87 | 162 | | Kaolin | Tuning | 88 | 175 | +---------+--------+-------+-------------+ The current row and the following row: SELECT name, test, score, SUM(score) OVER (ORDER BY score ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS total_score FROM student_test ORDER BY score; +---------+--------+-------+-------------+ | name | test | score | total_score | +---------+--------+-------+-------------+ | Esben | Tuning | 31 | 74 | | Esben | SQL | 43 | 130 | | Kaolin | SQL | 56 | 172 | | Chun | Tuning | 73 | 204 | | Chun | SQL | 75 | 235 | | Tatiana | SQL | 87 | 250 | | Kaolin | Tuning | 88 | 175 | +---------+--------+-------+-------------+ URL: https://mariadb.com/kb/en/window-frames/https://mariadb.com/kb/en/window-frames/