我无法使用SQLite窗口功能(例如LAG,LEAD)。经过一些调查,这似乎是由于SQLite数据库版本低于3.25.0,此后才提供了窗口功能。
Database created using SQLite 3.30.1 version
However version 3.24.0 version displayed on this 'test' database
[当测试包含窗口函数的查询时,例如sqlitetutorial site上提供的查询:the following errors are displayed
您能否建议如何解决此问题。非常感谢您的支持。
SELECT CustomerId, Year, Total,
LAG (Total, 1, 0) OVER (ORDER BY Year) PreviousYearTotal
FROM CustomerInvoices
WHERE CustomerId = 4;
发生了同样的问题。看来您正在使用SQLiteStudio,最新版本为2019年12月,为3.21。虽然您的数据库是在SQLite 3.30中创建的(并且您的软件可能正在使用3.30),但您使用的SQLiteStudio的版本却基于3.24。
[outstanding feature request用于在SQLiteStudio中实现窗口功能。在此之前,您所能做的最好的就是将SQLiteStudio程序目录中的sqlite3.dll替换为较新的版本(3.30,32位版本)。窗口函数将显示为语法错误,但查询仍将执行。