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?

Russian Language

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

SELECT * FROM #Hours

SELECT *
INTO #MyPosts
FROM Posts
WHERE
  PostTypeId IN (1, 2) AND
  OwnerUserId = @UserID

SELECT
  h.Hours,
  datepart(hour, CreationDate),
  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, CreationDate
ORDER BY h.Hours

Enter Parameters

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