On Feb 17, 10:52 pm, Phlip <phlip2...@gmail.com> wrote: > Djangoists: > > I have a database table like this... > > red, 1 > red, 2 > red, 15 > blue, 18 > blue, 20 > > ...and I want to read it into an array like this: > > [ ['red', [1,2,15]], ['blue', [18,20]], ] > > Of course I can use values_list('color', 'number'), and then re-pack > the array with a for-loop. > > Do QuerySet aggregations and annotations offer some way to push that > query into the database?
Assuming you want an output in array format (as per the first part of your question): http://stackoverflow.com/questions/1859031/how-could-create-a-crosstab-sql-query-with-django-orm -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.