SELECT dateadd(month, datediff(month, 0, CreationDate), 0...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Software Engineering

Q&A for professionals, academics, and students working within the systems development life cycle

SELECT
    dateadd(month, datediff(month, 0, CreationDate), 0) as [Month],
    COUNT(1) [Number of negative scored questions]
--    Avg(CASE PostTypeID WHEN 1 THEN Cast(Score AS Float) END) AS [Questions]
  FROM Posts
  WHERE (PostTypeId = 1 OR PostTypeId = 2)
  AND Score < 0
  AND PostTypeID = 1
  AND CreationDate >= '1/1/2011'
  GROUP BY dateadd(month, datediff(month, 0, CreationDate), 0)
UNION
SELECT
    dateadd(month, datediff(month, 0, CreationDate), 0) as [Month],
    COUNT(1) [Number of positive scored questions]
--    Avg(CASE PostTypeID WHEN 1 THEN Cast(Score AS Float) END) AS [Questions]
  FROM Posts
  WHERE (PostTypeId = 1 OR PostTypeId = 2)
  AND Score > 0
  AND PostTypeID = 1
  AND CreationDate >= '1/1/2011'
  GROUP BY dateadd(month, datediff(month, 0, CreationDate), 0)
ORDER BY [Month]

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results