Negatively scored answers on Stack Overflow - aggregation by last edit date

1

Please login or register to vote for this query.

(click on this box to dismiss)

Calculates DV questions based on their last edit date *only*.

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT p.Score,
  COUNT(*) AS downvoted_all_time,
  SUM(CASE WHEN DATEDIFF(day, p.LastEditDate, getdate()) > 30 THEN 1 ELSE 0 END) AS active_last_thirty_days,
  SUM(CASE WHEN DATEDIFF(day, p.LastEditDate, getdate()) > 60 THEN 1 ELSE 0 END) AS active_last_sixty_days,
  SUM(CASE WHEN DATEDIFF(day, p.LastEditDate, getdate()) > 90 THEN 1 ELSE 0 END) AS active_last_ninety_days,
  SUM(CASE WHEN DATEDIFF(day, p.LastEditDate, getdate()) > 180 THEN 1 ELSE 0 END) AS active_last_180_days,
  SUM(CASE WHEN DATEDIFF(year, p.LastEditDate, getdate()) > 1 THEN 1 ELSE 0 END) AS active_last_year
FROM Posts p
  LEFT JOIN Votes v ON p.Id = v.PostId
WHERE p.PostTypeId = 2
GROUP BY p.Score
HAVING p.Score <= -1 AND p.Score >= -100
ORDER BY p.Score DESC

Enter Parameters

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