ค้นหาจำนวนการโหวตลงของโพสต์ ไม่จำเป็นต้องใช้ตารางทั้งหมด
Find amount of downvotes of a post.It is not neccessary to use all the tables.
 ReviewTaskStates:  Id [ number]  Name [ text]  Description [ text] 
SELECT UpVotes, DownVotes, COUNT(*) AS AnswersCount 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 Posts INNER JOIN Votes ON Votes.PostId = Posts.Id AND (VoteTypeId = 2 OR VoteTypeId = 3) WHERE Posts.Id = @UserId GROUP BY Posts.Id) AS VotesCount GROUP BY UpVotes, DownVotes ORDER BY UpVotes DESC