Posts with highest score from anonymous feedback

1

Please login or register to vote for this query.

(click on this box to dismiss)

Vegetarianism

Q&A for those committed to a vegan or vegetarian lifestyle and anyone interested in learning more

SELECT TOP(##mum?500##)
  RANK() OVER(ORDER BY SUM(Case pf.VoteTypeId When 2 Then 1 WHEN 3 Then -1 End) DESC) AS Rank,
  pf.PostId as [Post Link],
  SUM(Case When pf.VoteTypeId = 2 Then 1 Else NULL End) AS UpFeedback,
  SUM(Case When pf.VoteTypeId = 3 Then 1 Else NULL End) AS DownFeedback,
  SUM(Case pf.VoteTypeId When 2 Then 1 WHEN 3 Then -1 End) AS Score,
  p.OwnerUserId AS [User Link], p.Score
FROM
  PostFeedback pf
JOIN Posts p ON p.Id = pf.PostId
GROUP BY pf.PostId, p.OwnerUserId, p.Score
ORDER BY SUM(Case pf.VoteTypeId When 2 Then 1 WHEN 3 Then -1 End) DESC

Enter Parameters

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