Re: Django aggregates and having

2009-08-12 Thread Alex Gaynor
On Wed, Aug 12, 2009 at 1:34 AM, lfrodrigues wrote: > > Sorry I didn't explain my self properly. > > I want this query: > SELECT (date_format(date, '%%U')) AS `d`, SUM > (`profile_scorehistory`.`points`) AS `l` FROM `profile_scorehistory` > GROUP BY date_format(date, '%%U') HAVING  `d`= 2 > > How

Re: Django aggregates and having

2009-08-11 Thread lfrodrigues
Sorry I didn't explain my self properly. I want this query: SELECT (date_format(date, '%%U')) AS `d`, SUM (`profile_scorehistory`.`points`) AS `l` FROM `profile_scorehistory` GROUP BY date_format(date, '%%U') HAVING `d`= 2 How can I make it with ORM? The other one was the only similar query I

Re: Django aggregates and having

2009-08-11 Thread Russell Keith-Magee
On Wed, Aug 12, 2009 at 5:50 AM, lfrodrigues wrote: > > Hi, > > I'm having some problems with "having": > > I want to group by date and restrict to a given week, in my tests I > can do this: > select_data = {"d": """date_format(date, '%%U')"""} > ScoreHistory.objects.extra(select=select_data).valu