Created
March 26, 2014 19:02
-
-
Save YanTheFawn/9790803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT ordered_posts.vote_score as vote_score,(CASE WHEN current_user_subscriptions.user_id IS NULL THEN '0' ELSE '1' END) as user_is_following, ordered_posts.influencer_id, current_user_subscriptions.user_id | |
FROM (SELECT * FROM posts ORDER BY vote_score desc) as ordered_posts | |
LEFT OUTER JOIN | |
(SELECT * FROM influencer_subscriptions WHERE user_id = 1) AS current_user_subscriptions | |
ON ordered_posts.influencer_id = current_user_subscriptions.influencer_id | |
WHERE ordered_posts.community_board = TRUE | |
GROUP BY influencer_id | |
ORDER BY user_is_following desc, ordered_posts.created_at desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment