SELECT POSTID, SUM(CASE WHEN ID = 2 THEN 1 ELSE 0 END) AS...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu

Q&A for Ubuntu users and developers

SELECT POSTID,
SUM(CASE WHEN ID = 2 THEN 1 ELSE 0 END) AS UPVOTES,
SUM(CASE WHEN ID = 3 THEN 1 ELSE 0 END) AS DOWNVOTES
FROM VOTES 
WHERE VOTETYPEID IN (2,3)
GROUP BY POSTID
ORDER BY UPVOTES DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results