Try django-cubes regards, gms
On Thu, Jan 12, 2012 at 12:05 PM, pradyumna <joshi.pradyu...@gmail.com>wrote: > I am trying to use Django aggregation for an existing application that > uses the following sql query: > > select sum(count) as sum_country_count, count(country_abbr) as > country_cnt,country_abbr from > (select log_datetime, count(country_abbr) as count,country_abbr from > firewall where log_datetime>=DATE('2011-11-09') and > log_datetime<=DATE('2012-01-08') group by log_datetime,country_abbr) > country_logs group by country_abbr order by country_abbr; > > As you can see, there are multiple aggregations required in this > django query. > > I am able to able to do this: > > > z=Firewall.objects.values('log_datetime','country_abbr').annotate(date_cnt=Count('log_datetime'),country_cnt=Count('country_abbr')).order_by('- > country_cnt') > > and this takes care of inner loop. > > If I try to do multiple annotations, django raise error.: > > > z=Firewall.objects.annotate(country_cnt=Count('country_abbr')).annotate(cnt=Count('country_cnt')) > > Is there a way in Django where in the above sql query can be handled > in aggregation clause? > > Thanks. > > -- > 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. > > -- Girish M S -- 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.