select hour, count(*) count from ( select distinct date, ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

select hour, count(*) count
from
(
  select distinct date, userid, hour
  from
  (
    select distinct CONVERT(date, posts.creationdate) date,
                    owneruserid userid,
                    datepart(hh, posts.creationdate) as hour
    from posts
    join users on owneruserid = users.id
    where users.reputation >= 3000
      and posts.id > 19105810 -- after '2013-10-01'
  
    union all
  
    select distinct CONVERT(date, comments.creationdate) date,
                    userid,
                    datepart(hh, comments.creationdate) as hour
    from comments
    join users on userid = users.id
    where users.reputation >= 3000
      and comments.id > 19105810 -- after '2013-10-01'
  ) a
) a
group by hour
order by count desc

Enter Parameters

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