Average views per question per hour

0

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 [Month], 
sum(ViewCount)/sum(1) as AvgViews
from
(
  select CAST(
  cast(DATEPART(YYYY, CreationDate) as varchar) + '-' + cast(DATEPART(MM, CreationDate) as varchar) +'-'+cast(DATEPART(DD,CreationDate) as varchar)+ ' '+ cast(DATEPART(HH, CreationDate) as varchar)+':00:00'
    as datetime) [Month], 
    PostTypeId,ViewCount
     
  from Posts p where posttypeid=1 and cast(DATEPART(YYYY, CreationDate) as varchar)='2013' and cast(DATEPART(MM, CreationDate) as varchar)=7
) as X
group by [Month]
order by [Month] asc

Enter Parameters

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