Votes over time for a specific question and its answers


Please login or register to vote for this query.

(click on this box to dismiss)

Gets Score over Time for a specific post and any answers it may have. (If given an answer-post ID, it just fetches data for that answer.)

Blender Meta

Q&A about the site for people who use Blender to create 3D graphics, animations, or games

DECLARE @PostId INT = ##PostId##;

WITH VotesByDate AS (
        v.CreationDate AS [Date],
        CASE    p.PostTypeId
            WHEN    1   THEN 'QST: ' + COALESCE (u.DisplayName, '*Dead User*')
            WHEN    2   THEN 'ANS: ' + COALESCE (u.DisplayName, '*Dead User*')
            ELSE    '?!?!'
        END AS PostHandle,
        SUM (
            CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE -1 END
        ) AS Vote

    FROM        Votes   v
    INNER JOIN  Posts   P
    ON    = v.PostId
    LEFT JOIN   Users   u
    ON    = p.OwnerUserId
    WHERE       v.PostId IN (
        FROM                Posts   q
        WHERE         = @PostId
        UNION ALL SELECT    a.Id
        FROM                Posts   a
        WHERE               a.ParentId  = @PostId
    AND         v.VoteTypeId IN (2, 3)
    GROUP BY    v.CreationDate, v.PostId, p.PostTypeId, u.DisplayName
    SUM (T.Vote) AS Score
FROM        VotesByDate p
LEFT JOIN   VotesByDate T
ON          T.[Date] <= p.[Date]  AND  T.PostHandle = p.PostHandle
GROUP BY    p.[Date], p.PostHandle
ORDER BY    p.[Date], p.PostHandle

Enter Parameters

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