QuestionsByDay

2

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

with QuestionDetail as (
    select DateAdd(dd, 1 - DatePart(dw, CreationDate), Convert(Date, CreationDate)) as Week,
           DateName(dw, CreationDate) as DayOfWeek,
           1 as QCount
    from Posts
    where PostTypeId = 1
      and ClosedDate is null
      and CommunityOwnedDate is null
      and CreationDate >= DateAdd(mm, -##Months:int?3##, Current_Timestamp)
)

select Week, [Monday], [Tuesday],  [Wednesday], [Thursday], [Friday], [Saturday], [Sunday]
from QuestionDetail
pivot ( sum(QCount) for DayOfWeek in ([Monday], [Tuesday],  [Wednesday], [Thursday], [Friday], [Saturday], [Sunday])) as pvt
order by Week

Enter Parameters

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