﻿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
32277	Support nested aggregates in window expressions.	Héctor Pablos	nobody	"When trying do something like

  {{{#!python
  Sum(Count('field_name'))
  }}}

Django raises a FieldError exception with the message {{{Cannot compute Sum('count'): 'count' is an aggregate""}}}. That makes sense except when  {{{Sum(Count())}}} is the expression of a Window function, where nesting two aggregates is a valid SQL expression:

  {{{#!python
  Window(expression=Sum(Count('field_name')), **omitted_window)
  }}}

I may be missing some edge case here but would it be possible to check, in the django.db.aggregates.Aggregate Func resolve_expression method, whether the expression containing another aggregate is the main expression of a Window function and, in that case, allow the execution of the SQL? Or is there any way to circumvent this aggregation nesting limitation in window functions?"	New feature	new	Database layer (models, ORM)	dev	Normal		window, aggregates	Mads Jensen John Speno	Accepted	0	0	0	0	0	0
