Skip to content

Instantly share code, notes, and snippets.

@secretrobotron
Created July 21, 2015 21:10
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 secretrobotron/52973ecd6bbaeddb33ef to your computer and use it in GitHub Desktop.
Save secretrobotron/52973ecd6bbaeddb33ef to your computer and use it in GitHub Desktop.
filter and prioritize by specific country
SELECT * FROM projects INNER JOIN users ON users.id = projects.user_id WHERE projects.deleted_at IS NULL AND projects.featured = TRUE
ORDER BY
CASE country
WHEN 'CA' THEN 1
ELSE 2
END , projects.created_at DESC LIMIT 50 OFFSET 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment