Q&A about the site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation
SELECT A.Count as 'Votes', COUNT(*) as 'Count', ROUND(COUNT(*) / (CAST(B.Total AS float)) * 100, 5) as '%age'
COUNT(*) AS 'Count'
ON Votes.PostId = Posts.Id
WHERE Votes.VoteTypeId = 2 or Votes.VoteTypeId = 3
GROUP BY Posts.Id) as A
COUNT(*) as 'Total'
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;