Posts by hour and day

0

Please login or register to vote for this query.

(click on this box to dismiss)

The number of posts in the last year occuring on each day of the week and each hour of the day

Mathematics

Q&A for people studying math at any level and professionals in related fields

-- Posts by hour and day
-- The number of posts in the last year occuring on each day of the week and each hour of the day

declare @start datetime, @total float

select @start = dateadd(d, -365, max(CreationDate))
from posts

select @total = count(*)
from posts
where CreationDate > @start

select datepart(hh, CreationDate) hour, datename(dw, CreationDate) day, count(*) posts, convert(varchar(6), round((count(*) / @total) * 100, 2)) + '%' pct
from posts
where creationDate > @start
group by datepart(hh, CreationDate), datename(dw, CreationDate)
order by count(*)

Enter Parameters

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