Response rate over day of week

1

Please login or register to vote for this query.

(click on this box to dismiss)

Linguistics Meta

Q&A about the site for professional linguists and others with an interest in linguistic research and theory

DECLARE @startdate as date, @enddate as date

-- It should be noted that dates should be given with single quote
-- e.g.    '2016-04-22'
SET @startdate = cast(##startdate## as date)
SET @enddate = cast(##enddate?GETDATE()## as date)

select 
      dayId, 
      numberOfQuestionWithAnAnswer, 
      numberOfQuestions, 
      cast(numberOfQuestions AS float) / cast(numberOfQuestionWithAnAnswer AS float) as responseRate
from (
  select DATEPART(dw, CreationDate) as dayId,
         count(*) as numberOfQuestions,
         sum(case when acceptedAnswerId is null then 0 else 1 end) as numberOfQuestionWithAnAnswer
  from Posts
  where PostTypeId=1 and CreationDate between @startdate and @enddate
  group by DATEPART(dw, CreationDate)
) as data

Enter Parameters

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