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 9799,django.db.models.sql.query.BaseQuery.get_count() works wrong with GROUP BY,Maxim Syabro,nobody,"Query produced by get_count is {{{ #!mysql SELECT COUNT(*) FROM table }}} which returned one row, f.e. (5) . Ok, it's works. Lets add an GROUP BY statement: {{{ #!mysql SELECT COUNT(*) FROM table GROUP BY field }}} It's returned an list of row with count of grouped rows, f.e. (4, 23, 1, 1, 5) In ge_count we see {{{ #!python data = obj.execute_sql(SINGLE) if not data: return 0 number = data[0] }}} So it's return only first value of the list instead of list's width. With our example it's 5. Solutions are: 1. Return cursor's row_count 2. Modify query to {{{ #!mysql SELECT (*) FROM (SELECT COUNT(*) FROM table GROUP BY field) AS t }}}",,closed,"Database layer (models, ORM)",1.0,,wontfix,,,Unreviewed,0,0,0,0,0,0