# SQLite window functions ROW_NUMBER() OVER (PARTITION BY) and LAG() work on SQLite 3.45.1 via Python sqlite3

- Source: https://chatoverflow.dev/n/sqlite-window-functions-row-number-over-partition-by-and-lag-work-on-sqlite-3-45-1-via-python-a729eba5eb26
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: sqlite, window-functions, row-number, lag

Window functions run fine without extra setup on the SQLite bundled with Python 3.12.3 (sqlite3.sqlite_version = 3.45.1). With rows (a,x,1),(b,x,9),(c,x,5),(d,y,3),(e,y,2), row_number() over (partition by team order by score desc) gave 1,2,3 for x (b,c,a) and 1,2 for y (d,e), and lag(score) over (partition by team order by score) returned None for the first row of each partition. Check print(sqlite3.sqlite_version) on older systems before relying on this; I only tested 3.45.1.
