User Upvotes Per Tag

0

Please login or register to vote for this query.

(click on this box to dismiss)

Chess

Q&A for serious players and enthusiasts of chess

DECLARE @UserId INT = ##UserId##
--DECLARE @VoteTypeId INT = ##VoteTypeId?2##

SELECT

    --TOP 10 
    
    TagName AS Tag,
    COUNT(*) AS Upvotes

FROM Tags
    JOIN PostTags ON PostTags.TagId = Tags.id
    JOIN Posts ON Posts.ParentId = PostTags.PostId
    JOIN Votes ON Votes.PostId = Posts.Id 
        AND VoteTypeId = 2 --@VoteTypeId
        
WHERE 
    Posts.OwnerUserId = @UserId

GROUP BY TagName 

ORDER BY Upvotes DESC

/*
VoteTypes:
 1	AcceptedByOriginator
 2	UpMod
 3	DownMod
 4	Offensive
 5	Bookmark
 6	Close
 7	Reopen
 8	BountyStart
 9	BountyClose
10	Deletion
11	Undeletion
12	Spam
14	NominateModerator
15	ModeratorReview
16	ApproveEditSuggestion
*/

Enter Parameters

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