Right now I am wasting a query and also losing the order of Users. Was
wondering what t he proper way to do this query is?
@top_tipper_ids = Tip.find_by_sql("SELECT SUM(tips.amount_cents)
total_tip, tips.client_id FROM tips WHERE tips.vendor_id = #[email protected]}
GROUP BY tips.client_id ORDER BY total_tip").collect {|e| e.client_id}
@top_tippers = User.find_all_by_id(@top_tipper_ids)
Trying to find the top tippers (Users) for a specific vendor.
--
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.