Average number of answers depending on day (or time) when bounty was started

1

Please login or register to vote for this query.

(click on this box to dismiss)

Emacs

Q&A for those using, extending or developing Emacs

/*
The usage of Period to switch between daily hours/hour and day in week is borrowed from https://data.stackexchange.com/math/query/155865/best-time-to-ask-questions-on-stackexchange-more-likely-to-get-an-answer
https://meta.stackexchange.com/questions/213603/question-and-answer-activity-on-stack-exchange-interactive-and-customized-editi
*/
DECLARE @Frequency int = ##Frequency:int?2##

;WITH tmp AS
(SELECT p.AnswerCount AS ACount,
    Period = CASE @Frequency
    WHEN 1 THEN DATEPART("hour", bs.CreationDate)
    WHEN 2 THEN DATEPART("weekday", bs.CreationDate)
    WHEN 3 THEN ROUND((CAST(DATEPART("weekday", bs.CreationDate) AS numeric)
    + CAST(DATEPART("hour", bs.CreationDate) AS numeric) / 24), 2) END
FROM Posts p INNER JOIN Votes bs
    ON p.Id = bs.PostId
    AND bs.VoteTypeId = 8  -- BountyStart
)
SELECT Period, AVG(cast(ACount as decimal))
FROM tmp
GROUP BY Period
ORDER BY Period

Enter Parameters

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