I tried a few more times and I couldn't get it to work. The "where" clause in mysql just wouldn't recognize an aliased sum or count column. So I dug through the mysql manual a bit and I came up with this;
:joins=>["INNER JOIN tasks ON tasks.project_id = projects.id"],
:select=>'*, SUM(tasks.id) AS sum_amount',
:having => "sum_amount > 5"
I just replaced "condiditions" with "having", which is apparently needed for sum columns. Now it works perfectly ^^ From what I've read the same syntax applies for SQLite.
Note for testing purposes I summed the ids from the Tasks model which obviously doesn't have any real use. Also you have to put a "*," in your select before the SUM so you still get your record attributes as well as the sum value.
This was the explanation I found;
When selecting count, sum, or some other aggregate function, the value isn
Last edited by marsvin (2009-03-28 12:05:56)