Total anonymous feedback for given user

0

Please login or register to vote for this query.

(click on this box to dismiss)

Sum of up and down votes for all posts of a given user.

Stack Overflow

Q&A for programmers

-- DECLARE @UserId INT = ##UserId##;

SELECT TOP 15
       u.id
     , u.DisplayName
     , COUNT(*) AS posts
     , COUNT(CASE WHEN pf.VoteTypeId = 2 THEN 1 ELSE NULL END) AS Anon_up
     , COUNT(CASE WHEN pf.VoteTypeId = 3 THEN 1 ELSE NULL END) AS Anon_down
FROM   Tags         t
JOIN   PostTags     pt ON pt.TagId = t.id
JOIN   PostFeedback pf ON pf.PostId = pt.PostId
JOIN   Posts        p  ON p.Id = pt.PostId
JOIN   Users        u  ON u.Id = p.OwnerUserId
WHERE  t.TagName = 'postgresql'
GROUP  BY u.id, u.DisplayName
ORDER  BY posts DESC;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results