SELECT content_id,
SUM(CASE WHEN value=1 THEN 1
WHEN value=0 THEN -1
ELSE 0
END) AS ContentSum
FROM votingapi_vote
WHERE value_type = 'option'
GROUP BY content_id
ORDER BY ContentSum DESC