Anton.Sandbox

1

Please login or register to vote for this query.

(click on this box to dismiss)

Code Golf and Coding Challenges Meta

Q&A about the site for programming puzzle enthusiasts and code golfers

-- 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  *, (DATEPART("weekday", CreationDate) + DATEPART("hour", CreationDate) / 24) AS cd
  FROM    Posts
  )
SELECT
    cd,
    COUNT(*) AS [Number of posts]
  FROM grouped
  GROUP BY cd

Enter Parameters

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