Q&A for students, teachers, polyglots, and anyone interested in the techniques of second-language acquisition
-- At what hour do I ask most posts, both questions and answers? -- UTC (GMT) time zone. The week starts with Sunday. -- Parameters: -- UserId -- HourOrDOW (1 - hours, 2 - day of week) -- DEFINE @var = DATEPART("weekday", CreationDate), DATENAME("hour", CreationDate); WITH grouped AS ( SELECT *, (CAST(DATEPART("weekday", CreationDate) AS int) + CAST(DATEPART("hour", CreationDate) AS int) / 24) AS cd FROM Posts ) SELECT cd, COUNT(*) AS [Number of posts] FROM grouped GROUP BY cd SELECT DATEPART("weekday", CreationDate), DATEPART("hour", CreationDate), round(CAST(DATEPART("hour", CreationDate) as numeric) / 24, 2) FROM Posts WHERE OwnerUserId = ##UserId##