I''m wondering if Rails fully supports grouping by multiple items? I
have a situation where I''d like to get total amounts grouped by year,
then month. Ideally, the result set would have the sum for the year
and for each month right there, although I imagine having the sum for
the year is probably a lot to ask.
In any case, I''m using MySQL. This is the code I would expect to
work:
@totals = Purchase.sum(:amount,
:group => "YEAR(updated_at),
MONTH(updated_at)",
:order => "updated_at DESC" )
The grouping appears to happen correctly. However, the result set is
restricted to months:
[["4", 37383437], ["3", 37506978], ["2",
84938573], ["1", 48391034],
["12", 48593943], ... ]
I could make some assumptions, counting back the years in my reporting
view. But I''d rather have all the actual data in one fell swoop.
Any help?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---