Skip to content

Instantly share code, notes, and snippets.

@sprite2005
Created August 10, 2010 10:31
Show Gist options
  • Save sprite2005/517059 to your computer and use it in GitHub Desktop.
Save sprite2005/517059 to your computer and use it in GitHub Desktop.
@top_tipper_ids = Tip.find_by_sql("SELECT SUM(tips.amount_cents) total_tip, tips.client_id FROM tips WHERE tips.vendor_id = #{@user.id} GROUP BY tips.client_id ORDER BY total_tip").collect {|e| e.client_id}
@top_tippers = User.find_all_by_id(@top_tipper_ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment