Top votes posts - only votes cast between two dates + restriction on posts creationdate

1

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

SELECT TOP(##num?500##)
  p.Id AS [Post Link], 
  SUM(Case When v.VoteTypeId = 2 Then 1 Else NULL End) AS UpVotes,
  SUM(Case When v.VoteTypeId = 3 Then 1 Else NULL End) AS DownVotes,
  SUM(Case v.VoteTypeId When 2 Then 1 WHEN 3 Then -1 End) AS Score,
  p.CreationDate,
  CASE p.PostTypeId
    WHEN 1 THEN 'Question'
    WHEN 2 THEN 'Answer'
  END,
  p.ViewCount, p.AnswerCount, p.Tags, p.FavoriteCount
FROM Votes v INNER JOIN Posts p ON v.PostId=p.Id
WHERE (p.PostTypeId IN (##types?1,2##)) AND
  (v.CreationDate >= '##Date1?2021-01-01##') AND
  (v.CreationDate <= '##Date2?2022-01-01##') AND
  (p.CreationDate >= '##Date3?1900-01-01##') AND
  (p.CreationDate <= '##Date4?2021-01-01##')
GROUP BY p.Id, p.CreationDate, p.PostTypeId, p.ViewCount, p.AnswerCount, p.Tags, p.FavoriteCount  
ORDER BY SUM(Case v.VoteTypeId When 2 Then 1 WHEN 3 Then -1 End) DESC

Enter Parameters

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