Average score of accepted answers in YEAR

0

Please login or register to vote for this query.

(click on this box to dismiss)

SharePoint

Q&A for SharePoint enthusiasts

declare @Year int = 2024

select @Year AS "Year", AVG(a.score) AS "Average Score", COUNT(*) AS "Score Count" 
from posts q 
join posts a on q.acceptedanswerid = a.id --- join q's with a's
join votes v on a.id = v.postid
where q.posttypeid=1 --- questions
and q.AcceptedAnswerId IS NOT NULL
and v.votetypeid=1 --- accepted by originator
and YEAR(v.creationdate)=2024 --- in 2023
;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results