SELECT DATEFROMPARTS( DATEPART(yyyy, CreationDate), DATEP...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT 
    DATEFROMPARTS(
    DATEPART(yyyy, CreationDate),
    DATEPART(mm, CreationDate),
    1) AS Month, 
    (CAST(SUM(Score * (CASE WHEN PostTypeId=1 AND ClosedDate is Null  THEN 1 ELSE 0 END)) as float)/(1.0 + CAST(SUM((viewCount) * (CASE WHEN PostTypeId = 1 AND ClosedDate is Null THEN 1 ELSE 0 END)) AS float))) AS AvgScoreOpenQ,
    (CAST(SUM(Score * (CASE WHEN PostTypeId=1 AND ClosedDate is not Null  THEN 1 ELSE 0 END)) as float)/(1.0 + CAST(SUM((viewCount) * (CASE WHEN PostTypeId = 1 AND ClosedDate is not Null THEN 1 ELSE 0 END)) AS float))) AS AvgScoreCloseQ
FROM POSTS

GROUP BY DATEFROMPARTS(
    DATEPART(yyyy, CreationDate),
    DATEPART(mm, CreationDate),
    1)
    
ORDER BY MONTH

Enter Parameters

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