Q&A for students and teachers of all martial arts
declare @YearStart DATETIME = '2023-01-01' declare @Year INT = YEAR(@YearStart) select DATEPART(q, v.creationdate) AS "Quarter", AVG(cast(a.score AS decimal)) AS "Average Score", MIN(a.score) AS "Min Score", MAX(a.score) AS "Max 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)=@Year -- in 2023 group by DATEPART(q, v.creationdate) order by DATEPART(q, v.creationdate) ;