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'
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;