Average votes of answers for users with at least MinAnswers answers
Q&A about the site for professional robotic engineers, hobbyists, researchers and students
-- Average number of votes per question SELECT 1 AS [Site], Count(*) AS [Votes], Count(CASE v.VoteTypeID WHEN 2 THEN 1 END) AS [Upvotes], Count(CASE v.VoteTypeID WHEN 3 THEN 1 END) AS [Downvotes] FROM votes v JOIN posts p ON v.postid=p.id WHERE p.posttypeid = 1 and p.closeddate is null and ( DATEPART(YYYY, p.creationdate) > ##YYYY## or ( DATEPART(YYYY, p.creationdate) = ##YYYY## and DATEPART(MM, p.creationdate) >= ##MM## ) ) and ( v.VoteTypeId = 2 or v.VoteTypeId = 3 ); SELECT 1 AS [Site], Count(*) AS [Posts] FROM posts p;