Score graph

1

Please login or register to vote for this query.

(click on this box to dismiss)

Emacs

Q&A for those using, extending or developing Emacs

WITH Scores AS (
SELECT CreationDate AS [Date],
  SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE -1 END) AS Score
  FROM Votes AS v1
  WHERE PostId = ##PostId:int##
    AND VoteTypeId IN (2, 3)
  GROUP BY CreationDate
),
Dates AS (
SELECT DISTINCT(CreationDate) AS [Date]
  FROM Votes
  WHERE CreationDate >=
  (SELECT DATEADD(DAY, DATEDIFF(DAY, 0, CreationDate), 0)
     FROM Posts WHERE Id = ##PostId:int##)
)
SELECT Dates.[Date], SUM(Scores.Score)
  FROM Dates
  INNER JOIN Scores
    ON Dates.[Date] >= Scores.[Date]
  GROUP BY Dates.[Date]
  ORDER BY Dates.[Date]

Enter Parameters

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