﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32463	'Sum' aggregate function not working with Window function on SQLite.	blackhorsesacher	nobody	"'Sum' aggregate function not working with Window function for sqlite3 version 3.27.2
Produces these errors:
{{{
>>>sqlite3.OperationalError: near ""OVER"": syntax error
>>>django.db.utils.OperationalError: near ""OVER"": syntax error
}}}
This is similar to the fixed issue #30027 ""SQLite (pre 3.25.0) does not support window functions, raises OperationalError"", but I am using SQLite 3.27.2 and the native SQL query is working from sqlite3 command line and also when using Model.objects.raw(), which I'm having to use as a workaround.
It should be reproducible as follows, assuming model ""myapp.mymodel"" has a field ""amount"":
{{{
>>> from django.db.models import Sum, Window
>>> from myapp.models import mymodel
>>> mymodel.objects.all().annotate(cumsum=Window(expression=Sum('amount')))
}}}
The raw query works OK:
{{{
>>> rawqs=mymodel.objects.raw(""SELECT *, SUM (amount) OVER (ORDER BY id) AS cumsum FROM myapp_mymodel"")
}}}"	Bug	closed	Database layer (models, ORM)	3.1	Normal	duplicate			Unreviewed	0	0	0	0	0	0
