User Activity by UTC Hour

0

Please login or register to vote for this query.

(click on this box to dismiss)

What time of day do I post questions and answers most?

Arts and Crafts Meta

Q&A about the site for artists and crafters

-- 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
INTO    #Hours
FROM    master.dbo.spt_values x
WHERE   x.type = 'P'        
AND     x.number <= 23;

SELECT * FROM #Hours

SELECT
  h.Hours,
  COALESCE(count(CASE WHEN p.PostTypeId = 1 THEN 1 END), 0) AS Questions,
  COALESCE(count(CASE WHEN p.PostTypeId = 2 THEN 1 END), 0) AS Answers
FROM #Hours h
LEFT JOIN Posts p ON datepart(hour, CreationDate) = h.Hours
WHERE
  PostTypeId IN (1, 2) AND
  OwnerUserId = @UserID
GROUP BY h.Hours
ORDER BY h.Hours

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results