UNBOUNDED is used only inside window frame clauses (ROWS or RANGE) as part of the phrases UNBOUNDED PRECEDING or UNBOUNDED FOLLOWING. It signals that the frame starts with the first row in the partition (UNBOUNDED PRECEDING) or ends with the last row in the partition (UNBOUNDED FOLLOWING). When paired with BETWEEN, it creates running or cumulative calculations. If no BETWEEN is specified, UNBOUNDED PRECEDING is implied as the default frame start when ORDER BY is present. UNBOUNDED never appears by itself; it must be combined with PRECEDING or FOLLOWING. Attempting to use it outside a window definition raises a syntax error. Some dialects allow UNBOUNDED with RANGE but not ROWS for specific data types, so consult vendor docs.
UNBOUNDED PRECEDING, UNBOUNDED FOLLOWING, WINDOW FUNCTIONS, RANGE, ROWS, PARTITION BY, ORDER BY
SQL:2003
UNBOUNDED PRECEDING sets the frame start at the first row of the partition. UNBOUNDED FOLLOWING sets the frame end at the last row.
Not always. If BETWEEN is omitted, most databases assume "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" when ORDER BY is present.
Frames that include many rows can increase memory usage, but most engines optimize running-total calculations. Indexing the ORDER BY columns helps.
SQLite supports UNBOUNDED only from version 3.25 onward and only with ROWS frames. Ensure your version and syntax are correct.