SELECT CAST(DATEPART(weekday, BaseComments.[Date]) AS nv...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Meta Stack Overflow

Q&A about the site for professional and enthusiast programmers

SELECT

CAST(DATEPART(weekday, BaseComments.[Date]) AS nvarchar(MAX)) + ' - ' + DATENAME(weekday, BaseComments.[Date]) + ' / ' + CAST(BaseComments.[Hour] AS nvarchar(MAX)) + ':00 - ' + CAST(BaseComments.[Hour] AS nvarchar(MAX)) + ':59' AS Timeframe,
AVG(BaseComments.[Comment_Count]) AS [Average # of comments]



FROM

(
SELECT

COUNT(*) AS Comment_Count,
CAST(CreationDate AS Date) AS Date,
DATEPART(hour, CreationDate) AS Hour

FROM Comments

GROUP BY CAST(CreationDate AS Date),
DATEPART(hour, CreationDate)

) AS BaseComments

GROUP BY CAST(DATEPART(weekday, BaseComments.[Date]) AS nvarchar(MAX)) + ' - ' + DATENAME(weekday, BaseComments.[Date]) + ' / ' + CAST(BaseComments.[Hour] AS nvarchar(MAX)) + ':00 - ' + CAST(BaseComments.[Hour] AS nvarchar(MAX)) + ':59'

ORDER BY CAST(DATEPART(weekday, BaseComments.[Date]) AS nvarchar(MAX)) + ' - ' + DATENAME(weekday, BaseComments.[Date]) + ' / ' + CAST(BaseComments.[Hour] AS nvarchar(MAX)) + ':00 - ' + CAST(BaseComments.[Hour] AS nvarchar(MAX)) + ':59'

Enter Parameters

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