Description\n-----------\n\nBasic Syntax\n\n``sql\nframe_clause:\n  {ROWS | RANGE} {frame_border | BETWEEN frame_border AND frame_border}\n\nframe_border:\n  | UNBOUNDED PRECEDING\n  | UNBOUNDED FOLLOWING\n  | CURRENT ROW\n  | expr PRECEDING\n  | expr FOLLOWING\n`\n\nHow Window Frames Work\n\nA basic overview of window functions is described in Window Functions Overview. Window frames define which rows contribute to the current result.\n\nWindow frames are used by aggregate window functions. They are defined by the frame clause inside OVER (...).\n\nOVER () uses the whole result set.\n\nFor aggregate window functions, OVER (ORDER BY ...) uses a running frame by default. In MariaDB, that default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.\n\nFrame Bound Types\n\nCommon frame bounds include:\n\n All rows before the current row (UNBOUNDED PRECEDING), for example RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW .\n All rows after the current row (UNBOUNDED FOLLOWING), for example RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING .\n A set number of rows before the current row (expr PRECEDING), for example RANGE BETWEEN 6 PRECEDING AND CURRENT ROW .\n A set number of rows after the current row (expr FOLLOWING), for example RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING .\n* A specified number of rows both before and after the current row, for example RANGE BETWEEN 6 PRECEDING AND 3 FOLLOWING .\n\nROWS vs RANGE\n\nROWS counts physical rows. RANGE groups peer rows that share the same ORDER BY value.\n\nUse ROWS when you want strict row-by-row stepping. Use RANGE when tied sort values should be treated as one peer group.\n\nAggregate Functions Using Frames\n\nSee list here.\n\nExamples\n--------\n\nCREATE TABLE student_test` (\n  name char(10),\n  test char(10),\n  score tinyint(4)\n);\n\nINSERT INTO student_test VALUES \n    ('Chun', 'SQL', 75), ('Chun', 'Tuning', 73), \n    ('Esben', 'SQL', 43), ('Esben', 'Tuning', 31), \n    ('Kaolin', 'SQL', 56), ('Kaolin', 'Tuning', 88), \n    ('Tatiana', 'SQL', 87);\n\nSELECT name, test, score, SUM(score) \n  OVER () AS total_score \n  FROM student_test;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-frames