Percentage of upvotes

0

Please login or register to vote for this query.

(click on this box to dismiss)

MathOverflow

Q&A for professional mathematicians

SELECT
  SUM(Case When (v.VoteTypeId=2) Then 1 Else 0 End) AS [Upvotes],
  SUM(Case When (v.VoteTypeId=3) Then 1 Else 0 End) AS [Downvotes],
  ROUND((CAST(SUM(Case When (v.VoteTypeId=2) Then 1 Else 0 End) AS decimal))*100.0/(CAST(SUM(Case When (v.VoteTypeId IN (2,3)) Then 1 Else 0 End) AS decimal)),2) AS [Upvotes Percentage]
FROM Votes v

Enter Parameters

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