Q&A for people interested in the history and origins of science and mathematics
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", ((1.00 * StateTotal)/(SELECT sum(StateTotal) FROM CloseReview)) FROM CloseReview