Table of population as a function of number of votes on the post

1

Please login or register to vote for this query.

(click on this box to dismiss)

https://chat.stackexchange.com/transcript/message/49612762#49612762

Physical Fitness Meta

Q&A about the site for physical fitness professionals, athletes, trainers, and those providing health-related needs

SELECT A.Count as 'Votes', COUNT(*) as 'Count', ROUND(COUNT(*) / (CAST(B.Total AS float)) * 100, 5) as '%age'

FROM 

(SELECT
  COUNT(*) AS 'Count'
  FROM Posts
    JOIN Votes
    ON Votes.PostId = Posts.Id
  WHERE Votes.VoteTypeId = 2 or Votes.VoteTypeId = 3
  GROUP BY Posts.Id) as A

JOIN

(SELECT
  COUNT(*) as 'Total'
  FROM Posts
  WHERE Posts.PostTypeId = 1 or Posts.PostTypeId = 2 or Posts.PostTypeId = 3) as B

ON 1 = 1

GROUP BY A.Count, B.Total
ORDER BY '%age' DESC, 'Votes' DESC;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results