Skip to content

Instantly share code, notes, and snippets.

@methyl
Created April 5, 2014 17:44
Show Gist options
  • Save methyl/9995323 to your computer and use it in GitHub Desktop.
Save methyl/9995323 to your computer and use it in GitHub Desktop.
asd
Game.select('games.*, SUM(CASE WHEN votes.weight > 0 THEN votes.weight ELSE 0 END) as positive, SUM(CASE WHEN votes.weight < 0 THEN votes.weight ELSE 0 END) as negative').joins(:votes).group('games.id')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment