Q&A for students, teachers, polyglots, and anyone interested in the techniques of second-language acquisition
select h.hours as [Hour], count(postsCounter) as [Posts], count(commentsCounter) as [Comments], count(suggestedCounter) as [Suggested Edits], count(editsCounter) as [Edits], count(counter) as [Total Activity] from ( select datepart(hour, creationdate) as active, 1 as counter, 1 as postsCounter, NULL as commentsCounter, NULL as editsCounter, NULL as suggestedCounter from posts union all select datepart(hour, creationdate) as active, 1 as counter, NULL as postsCounter, 1 as commentsCounter, NULL as editsCounter, NULL as suggestedCounter from comments union all select datepart(hour, creationdate) as active, 1 as counter, NULL as postsCounter, NULL as commentsCounter, NULL as editsCounter, 1 as suggestedCounter from suggestededits union all select datepart(hour, creationdate) as active, 1 as counter, NULL as postsCounter, NULL as commentsCounter, 1 as editsCounter, NULL as suggestedCounter from posthistory ) as a right join ( select distinct datepart(hour, CreationDate) as hours from posts ) as h on a.active = h.hours group by h.hours order by h.hours