DECLARE @AID int = ##AnswerID## SELECT DATEFROMPARTS(YEA...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers Meta

Q&A about the site for Drupal developers and administrators

DECLARE @AID int = ##AnswerID##

SELECT
    DATEFROMPARTS(YEAR(v.CreationDate), MONTH(v.CreationDate), 1) AS [Year-Month],
    COUNT(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE NULL END) AS [Upvotes],
    ' ' AS Obsolete

FROM Posts answers
    INNER JOIN 
        Posts p ON answers.parentid = p.id
    INNER JOIN
        Votes v ON v.postid = p.id

WHERE v.VoteTypeId IN (2) -- Limit to Up/ Downvotes
    AND answers.id = @AID
    AND (v.CreationDate >= '##Date1?2016-07-01##') AND (v.CreationDate <= '##Date2?2021-10-01##')

GROUP BY DATEFROMPARTS(YEAR(v.CreationDate), MONTH(v.CreationDate), 1), v.postid, p.id

ORDER BY DATEFROMPARTS(YEAR(v.CreationDate), MONTH(v.CreationDate), 1) ASC

Enter Parameters

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