Average Score Open vs Closed Questions, all tags, last 5 years

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Apps

Q&A for apps, scripts, and development with the Stack Exchange API

select 
  eomonth(creationdate) as [Month End],
  case when sum(case when closeddate is null then 1 else 0 end) = 0 then 0 else        
      round(1.0*sum(case when closeddate is null then score else 0 end)/
      sum(case when closeddate is null then 1 else 0 end),3) end as [Avg Score: Open Qs],          
  case when sum(case when closeddate is not null then 1 else 0 end) = 0 then 0 else        
      round(1.0*sum(case when closeddate is not null then score else 0 end)/
      sum(case when closeddate is not null then 1 else 0 end),3) end as [Avg Score: Closed Qs],
  round(1.0*sum(score)/count(*),3) as [Avg Score: All Qs]
from posts
where 
  posttypeid=1
  and creationdate>=dateadd(yy,-5,getdate())
group by eomonth(creationdate)
order by eomonth(creationdate)

Enter Parameters

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