#30633: Group by concat(field1,field2) producing wrong result
-----------------------------------------+--------------------------------
               Reporter:  bishwadeep     |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  2.2
               Severity:  Normal         |       Keywords:  mysql group by
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+--------------------------------
 I am new to Django and I am enjoying it. I ran into an issue while
 creating a SQL query for my project. I want the following query to run
 using Django
 Query:
 Select id,field1,field2,field3 FROM table WHERE field1 = somevalue
 Group by concat(field1,field2) ORDER BY somefield

 However I am not able to get the desired query. It keeps on adding group
 by id which is not what I want.
 Django query:
 result = query.annotate(person=Concat(F('field1'),
 F('field2'))).annotate(Count('person', distinct=True))
 Outputs:
 SELECT id FROM table WHERE my condition GROUP BY id ORDER BY field

 Please let me know if you have any questions.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30633>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.c3a2cf804f382eeedaa75bc8f66bead1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to