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

0

Please login or register to vote for this query.

(click on this box to dismiss)

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

DECLARE @AID int = ##AnswerID##

SELECT
    DATEFROMPARTS(YEAR(v.CreationDate), MONTH(v.CreationDate), 1) AS [Year-Month],
    p.id AS [Question id],
    v.postid AS [Post Link],
    COUNT(*) AS [Upvotes],
    --SUM(Upvotes) AS [Upvotes-accum]
    --COUNT(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE NULL END) AS [Upvotes]
    --COUNT(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE NULL END) AS [Downvotes],
    --COUNT(*) AS [Up & Dwn Votes],
    --p.ViewCount AS [ViewCount]
    p.AnswerCount AS [AnswerCount]

FROM Posts answers
    INNER JOIN 
        Posts p ON answers.parentid = p.id
    INNER JOIN
        Votes v ON v.postid = p.id
    INNER JOIN 
        posttags pt ON pt.postid = p.id
    INNER JOIN 
        tags t ON pt.tagid = t.id
--WHERE v.VoteTypeId IN (2, 3) -- Limit to Up/ Downvotes
WHERE v.VoteTypeId IN (2) -- Limit to Upvotes
    AND answers.id = @AID
    AND (v.CreationDate >= '##Date1?2016-07-01##') AND (v.CreationDate <= '##Date2?2021-07-01##')
GROUP BY DATEFROMPARTS(YEAR(v.CreationDate), MONTH(v.CreationDate), 1), v.postid, p.id, p.AnswerCount
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