Q&A for Tridion developers and administrators
select datepart(year, creationdate) as Year , datepart(q, creationdate) as Quarter , count(*) as [Total] , count(case when closeddate is not null then 1 else null end ) as [Closed] , avg(case when datediff(d, creationdate, closeddate) <= 7 and closeddate is not null then datediff(s, creationdate, closeddate) end ) as [Average Close Time(s) - 7 days] , avg(case when datediff(d, creationdate, closeddate) <= 1 and closeddate is not null then datediff(s, creationdate, closeddate) end ) as [Average Close Time(s) - 1 day] , cast( 100.0 / cast(count(*) as float) * cast(count(case when closeddate is not null then 1 else null end) as float) as numeric(3,2) ) as [% Closed] from posts where posttypeid = 1 group by datepart(year, creationdate) , datepart(q, creationdate) order by datepart(year, creationdate) , datepart(q, creationdate)