#15709: Duplicated group_by condition --------------------------------+--------------------------- Reporter: ziangsong | Owner: nobody Status: new | Milestone: Component: Uncategorized | Version: 1.3 Keywords: group_by, annotate | Triage Stage: Unreviewed Has patch: 0 | --------------------------------+--------------------------- So I want to implement this SQL:
selelct id, count(*), max(insert_date) as m_d from Book group by id Here is the Django ORM query: q = Book.objects.values('id').annotate(c = Count('id'), m_d = Max('insert_date')).order_by() However, the translated sql is like this: selelct id, count(*), max(insert_date) as m_d from Book group by id, id <-here is another id! It messed up things! Btw, the id in Book is a foreign key to another table and I am using MySql database. -- Ticket URL: <http://code.djangoproject.com/ticket/15709> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.