AnswersByDay

1

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 AnswerDetail 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 = 2
      and CommunityOwnedDate is null
      and CreationDate >= DateAdd(mm, -##Months:int?3##, Current_Timestamp)
)

select Week, [Monday], [Tuesday],  [Wednesday], [Thursday], [Friday], [Saturday], [Sunday]
from AnswerDetail
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