select dateadd(week, datediff(week, 0, posthistory.creati...

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace

Q&A for members of the workforce navigating the professional setting

select dateadd(week, datediff(week, 0, posthistory.creationdate), 0),
sum(case when posthistory.posthistorytypeid = 1 then 1 else 0 end) as [asked],
sum(case when posthistory.posthistorytypeid = 10 then 1 else 0 end) as [closed],
sum(case when posthistory.posthistorytypeid = 11 then 1 else 0 end) as [reopened]
from posthistory
inner join posts on posthistory.postid = posts.id
where posthistory.creationdate between '5/1/2012' and dateadd(week, datediff(week, 0, GetDate()), 0)
and posts.posttypeid = 1
group by dateadd(week, datediff(week, 0, posthistory.creationdate), 0)
order by dateadd(week, datediff(week, 0, posthistory.creationdate), 0)

Enter Parameters

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