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,
WHEN state.Name = 'Completed' then 'Comp'
ELSE 'Not Completed'
END as StateBin
FROM ReviewTasks r
JOIN ReviewTaskStates state ON r.ReviewTaskStateId = state.Id
r.ReviewTaskTypeId = @CloseVoteReview
YEAR(r.DeletionDate) = 2021
AND MONTH(r.DeletionDate) = 12
GROUP BY Name
FORMAT(((1.00 * StateTotal)/(SELECT sum(StateTotal) FROM CloseReview)), 'P2') As "Percent"