[Answer]-Django 1.4/1.5 control GROUP BY combined with HAVING

1👍

It’s not pretty code but. Using django’s ‘extra’ queryset method and where as an argument you can achieve getting back the desired result set. i.e.

Table.objects.extra(where=['id IN (SELECT id FROM table_name' 
                           '       GROUP BY user_id HAVING MIN(time))'])

Leave a comment