By the way, the following works, but I was hoping that ActiveRecord
could assemble a query without so much exposed SQL. Does anyone have
anything better?
s = SalesFact.all(
:select => 'sold.short_month_name AS sold_month, ' +
'COUNT(*) as units_sold',
:joins => 'INNER JOIN date_dimensions listed ON listed.id =
sales_facts.listed_date_dimension_id ' +
'INNER JOIN date_dimensions sold ON sold.id =
sales_facts.sold_date_dimension_id',
:group => 'sold.short_month_name',
:order => 'sold.month_of_year'
) ; true
[For those watching at home, this counts how many sales closed in each
month of the year, and returns the result ordered from Jan ... Dec.]
--
Posted via http://www.ruby-forum.com/.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.