Anton.Sandbox

1

Please login or register to vote for this query.

(click on this box to dismiss)

Engineering

Q&A for professionals and students of engineering

-- At what hour do I ask most posts, both questions and answers?
-- UTC (GMT) time zone.

DECLARE @UserId int = ##UserId##;
DECLARE @Part varchar(10)

-- SELECT @Part = CASE ##HourOrDOW:int##
-- WHEN 1 THEN DATEPART("hour", CreationDate)
-- WHEN 2 THEN DATEPART("weekday", CreationDate)
-- ELSE DATEPART("hour", CreationDate)
-- END

-- ##HourOrDOW:string##

-- CASE ##HourOrDOW## WHEN 1 THEN "hour" WHEN 2 THEN "weekday" ELSE "hour" END

SELECT
  CASE ##HourOrDOW:int##
WHEN 1 THEN DATEPART("hour", CreationDate)
WHEN 2 THEN DATEPART("weekday", CreationDate)
ELSE DATEPART("hour", CreationDate)
END AS [Hour you add a post],
  COUNT(*) AS [Number of your posts]
FROM Posts
WHERE OwnerUserId = @UserId
GROUP BY CASE ##HourOrDOW:int##
WHEN 1 THEN DATEPART("hour", CreationDate)
WHEN 2 THEN DATEPART("weekday", CreationDate)
ELSE DATEPART("hour", CreationDate)
END

Enter Parameters

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