Re: Count users joined ordered by month

2011-08-05 Thread Simon Zimmermann
On Aug 5, 9:33 pm, Subhranath Chunder wrote: > Not the exact answer you were looking for, but I was only wondering, if you > have already figured the actual SQL query then why not simply use that > instead. You loose many things by not using the ORM. Currently I use raw() SQL for making these k

Re: Count users joined ordered by month

2011-08-05 Thread Subhranath Chunder
Not the exact answer you were looking for, but I was only wondering, if you have already figured the actual SQL query then why not simply use that instead. It's not mandatory to use the model query APIs, if your query is complex. Using the raw() API would still yield you model querysets or instanc

Count users joined ordered by month

2011-08-05 Thread Simon Zimmermann
In SQL we can do SELECT MONTH(date_joined), YEAR(date_joined), COUNT(id) as joined_month FROM auth_user GROUP BY MONTH(date_joined), YEAR(date_joined) ORDER BY YEAR(date_joined), MONTH(date_joined) Which yields a table like this MONTH(date_joined) YEAR(date_joined) joined_month 3