Skip to content

Instantly share code, notes, and snippets.

@wuputah
Created November 19, 2008 02:22
Show Gist options
  • Save wuputah/26384 to your computer and use it in GitHub Desktop.
Save wuputah/26384 to your computer and use it in GitHub Desktop.
named_scope :has_commissions, lambda { |amount| { :conditions => ["id IN (SELECT user_id FROM (SELECT user_id, SUM(amount) AS amount FROM commissions GROUP BY user_id HAVING amount > ?) AS a)", amount] } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment