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 11916 Extra params + aggregation creates incorrect SQL. jaklaassen@… nobody A query that has an annotation/aggregation (and thus a GROUP BY), extra (where) parameters and extra select parameters generates incorrect SQL because it puts the extra parameters at the end of the params list, although get_grouping() will generate parameters due to the extra select parameters. I have attached a diff for django.db.models.sql.query.py that should I believe addresses this problem. Uncategorized closed Database layer (models, ORM) 1.1 Normal fixed paluho@… Gabriel Hurley roberto.maurizzi@… Accepted 1 0 0 0 0 0