What time of day do I post questions and answers most?
Q&A for students, teachers, and linguists wanting to discuss the finer points of the Russian language
-- My Activity by UTC Hour
-- What time of day do I post questions and answers most?
DECLARE @UserID INT = ##UserID?9449426##
-- Create a table containing all the hours in a day (0-24)
SELECT x.number AS Hours
FROM master.dbo.spt_values x
WHERE x.type = 'P'
AND x.number <= 23;
SELECT * FROM #Hours
PostTypeId IN (1, 2) AND
OwnerUserId = @UserID
SUM(case when PostTypeId = 1 then 1 ELSE 0 END) as Questions,
SUM(case when PostTypeId = 2 then 1 ELSE 0 END) as Answers
FROM #Hours h
LEFT JOIN #MyPosts p ON datepart(hour, CreationDate) = h.Hours
GROUP BY h.Hours
ORDER BY h.Hours