Just wondering if it is possible to get a result that I can get using this SQL query with only Django ORM:
SELECT * FROM (SELECT DATE_FORMAT(created, "%Y") as dte, sum(1) FROM some_table GROUP BY dte) as analytics;
The result is:
+------+--------+
| dte  | sum(1) |
+------+--------+
| 2006 |     20 | 
| 2007 |   2230 | 
| 2008 |   4929 | 
| 2009 |   1177 | 
+------+--------+
The simplified model looks like this:
# some/models.py
class Table(models.Model):
   created = models.DateTimeField(default=datetime.datetime.now)
I've tried various ways using mix of .extra(select={}) and .values() and also using the .query.group_by trick described here but would appreciate a fresh eyes on the problem.