Global number of Upvotes/Downvotes and their Ratio

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow em Português

Perguntas e respostas para programadores profissionais e entusiastas

SELECT Upvotes, Downvotes, ROUND(Upvotes/Downvotes, 3) as Ratio
FROM (SELECT 
    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)
) as votecounts

Enter Parameters

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