﻿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
15709	Duplicated group_by condition	ziangsong	nobody	"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."	Cleanup/optimization	closed	Database layer (models, ORM)	1.3	Normal	fixed	group_by, annotate	ziangsong	Ready for checkin	1	0	0	0	0	0
