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