DECLARE @Days INT = ##Days##; SELECT TOP 50 p.Id AS [Pos...

0

Please login or register to vote for this query.

(click on this box to dismiss)

DevOps Meta

Q&A about the site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure

DECLARE @Days INT = ##Days##;

SELECT TOP 50
    p.Id AS [Post Link],
    SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS [Upvotes],
    SUM(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) AS [Downvotes],
    p.Score AS [answer score],
    p.CreationDate AS [Date Posted]
FROM Posts p
LEFT JOIN Votes v ON p.Id = v.PostId
WHERE
    p.PostTypeId = 2 AND
    DATEDIFF(day, p.CreationDate, GETDATE()) <= @Days
GROUP BY p.Id, p.Score, p.CreationDate
ORDER BY [answer score] DESC

Enter Parameters

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