Skip to content

Instantly share code, notes, and snippets.

@nicolasiensen
Created May 16, 2014 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolasiensen/50be3a50d98c9355293d to your computer and use it in GitHub Desktop.
Save nicolasiensen/50be3a50d98c9355293d to your computer and use it in GitHub Desktop.
def self.funders_or_sponsors(opts={})
find_by_sql <<-SQL
SELECT *
FROM (
(SELECT "users".* FROM "users" WHERE "users"."sponsor" = 't')
UNION
(SELECT DISTINCT "users".* FROM "users" INNER JOIN "successful_transactions" ON "successful_transactions"."user_id" = "users"."id")
) AS t
SQL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment