Most recent posts that reached a score of X in the first Y days.

0

Please login or register to vote for this query.

(click on this box to dismiss)

Open Data

Q&A for developers and researchers interested in open data

DECLARE @minScore numeric = ##MinScore?100##
DECLARE @ageDays numeric = ##Days?7##

SELECT TOP 1000
    (CASE Posts.PostTypeId
        WHEN 1 THEN 'Q'
        WHEN 2 THEN 'A'
     END),
    Posts.Id AS [Post Link],
    Posts.OwnerUserId AS [User Link],
    Posts.CreationDate AS [Date],
    Posts.Score AS [Score],
    SUM(CASE
        WHEN VoteTypeId = 2 THEN 1
        WHEN VoteTypeId = 3 THEN -1
    END) AS [Early Score]
FROM
    Votes
  INNER JOIN
    Posts ON Posts.Id = Votes.PostId
WHERE DATEDIFF(DAY,Posts.CreationDate,Votes.CreationDate) <= @ageDays
GROUP BY
    Posts.Id,
    Posts.OwnerUserId,
    Posts.PostTypeId,
    Posts.Score,
    Posts.CreationDate
HAVING
    SUM(CASE
        WHEN VoteTypeId = 2 THEN 1
        WHEN VoteTypeId = 3 THEN -1
    END) >= @minScore
ORDER BY [Date] DESC

Enter Parameters

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