Review queue vote type breakdowns

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT 
	ReviewTaskTypes.Id as ReviewTypeId,
	ReviewTaskTypes.Name as ReviewType, 
	ReviewTaskResultTypes.Name as Action, 
	COUNT(ReviewTaskResults.Id) as Count,
	(
		SELECT ROUND(100.0 * COUNT(ReviewTaskResults.Id) / COUNT(*), 2)
		FROM ReviewTaskResults reviewTaskResultsInner
		INNER JOIN ReviewTaskResultTypes ON ReviewTaskResultTypes.Id = reviewTaskResultsInner.ReviewTaskResultTypeId
		INNER JOIN ReviewTasks ON ReviewTasks.Id = reviewTaskResultsInner.ReviewTaskId
		INNER JOIN ReviewTaskTypes reviewTaskTypesInner ON reviewTaskTypesInner.Id = ReviewTasks.ReviewTaskTypeId
		WHERE reviewTaskTypesInner.Id = ReviewTaskTypes.Id
	) as Percentage,
	(
		SELECT COUNT(*) 
		FROM ReviewTaskResults
		INNER JOIN ReviewTaskResultTypes ON ReviewTaskResultTypes.Id = ReviewTaskResults.ReviewTaskResultTypeId
		INNER JOIN ReviewTasks ON ReviewTasks.Id = ReviewTaskResults.ReviewTaskId
		INNER JOIN ReviewTaskTypes reviewTaskTypesInner ON reviewTaskTypesInner.Id = ReviewTasks.ReviewTaskTypeId
		WHERE reviewTaskTypesInner.Id = ReviewTaskTypes.Id
	) as Total
FROM ReviewTaskResults
INNER JOIN ReviewTaskResultTypes ON ReviewTaskResultTypes.Id = ReviewTaskResults.ReviewTaskResultTypeId
INNER JOIN ReviewTasks ON ReviewTasks.Id = ReviewTaskResults.ReviewTaskId
INNER JOIN ReviewTaskTypes ON ReviewTaskTypes.Id = ReviewTasks.ReviewTaskTypeId
GROUP BY ReviewTaskTypes.Id, ReviewTaskTypes.Name, ReviewTaskResultTypes.Name
ORDER BY ReviewTaskTypes.Id, COUNT(ReviewTaskResults.Id) DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results