select dateadd(hh, dow * 24 + hour, convert(datetime,'20...

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

select dateadd(hh,  dow * 24 + hour, convert(datetime,'2021-06-26')) [dow]
     , sum(answercount) / convert(decimal,count(*))  [#avg answer]
     , sum(accept) / convert(decimal,count(*)) [#avg accept] 
    -- , log10(count(*)) [#q]
from (
select datepart(dw, creationdate) [dow]
     , datepart(hh, creationdate) [hour]
     , datepart(mi, creationdate) [minute]
     , answercount
     , case when acceptedanswerid is not null then 1 else 0 end accept
from posts
where posttypeid = 1
and answercount > 0
) data
group by dow * 24 + hour
order by 1 

select datepart(dw, getdate())

Enter Parameters

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