Posts that scored the highest in the first X days.

3

Please login or register to vote for this query.

(click on this box to dismiss)

A collection of posts that got a lot of early viral attention...

Economics

Q&A for those who study, teach, research and apply economics and econometrics

declare @ageDays numeric = ##Days##

declare @lastDate DATETIME
SET @lastDate = (SELECT MAX(CreationDate) FROM Votes)

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",
    [Age] = DATEDIFF(DAY,Posts.CreationDate,@lastDate),
    [Early Score] = SUM(CASE
        WHEN VoteTypeId = 2 THEN 1
        WHEN VoteTypeId = 3 THEN -1
    END),
    [Current Score] = Posts.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
order by
    [Early Score] desc

Enter Parameters

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