Re: Return multiple counts from the same table in one query?

2009-05-14 Thread Up2L8
Yeah, I've used count() before but I didn't see how to do 2 counts in the same query. I thought maybe the new annotate or aggregate stuff might help, but it wasn't obvious to me. Thanks, Eric On May 13, 8:30 pm, raman wrote: > This is a "count()" method for querysets: > > http://docs.djangopro

Re: Return multiple counts from the same table in one query?

2009-05-13 Thread raman
This is a "count()" method for querysets: http://docs.djangoproject.com/en/dev/ref/models/querysets/#count However, for this, it may be easiest to use raw sql within Django: http://docs.djangoproject.com/en/dev/topics/db/sql/ -Raman On May 13, 6:43 pm, Up2L8 wrote: > Is there a way to do so

Return multiple counts from the same table in one query?

2009-05-13 Thread Up2L8
Is there a way to do something like this in django? SELEC COUNT(t1.id), COUNT(t2.id) FROM Test_testrun t1 LEFT JOIN Test_testrun t2 ON t2.id = t1.id AND t2.passed=True Sorry for my newbness, I've been searching for awhile now with no luck. Eric --~--~-~--~~~---~--~-