SELECT POSTID, SUM(CASE WHEN VOTETYPEID = 2 THEN 1 ELSE 0...

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 VOTETYPEID = 2 THEN 1 ELSE 0 END) AS UPVOTES,
SUM(CASE WHEN VOTETYPEID = 3 THEN 1 ELSE 0 END) AS DOWNVOTES
FROM VOTES 
WHERE VOTETYPEID IN (2,3)
GROUP BY POSTID
ORDER BY UPVOTES ASC

Enter Parameters

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