Q&A for linguists, teachers, and students wanting to discuss the finer points of the Latin language
DECLARE @Question tinyint = 1; DECLARE @Answer tinyint = 2; DECLARE @CloseVoteReview tinyint = 2; DECLARE @Invalid tinyint = 3; WITH CloseReview AS ( SELECT state.Name as State, Count(*) as StateTotal FROM ReviewTasks r JOIN ReviewTaskStates state ON r.ReviewTaskStateId = state.Id WHERE r.ReviewTaskTypeId = @CloseVoteReview AND YEAR(r.DeletionDate) = 2021 AND MONTH(r.DeletionDate) = 12 GROUP BY Name ) SELECT State, StateTotal, ((100.00 * StateTotal)/(SELECT sum(StateTotal) FROM CloseReview)) As "Percent" FROM CloseReview