How many upvotes do I have for each tag?


Please login or register to vote for this query.

(click on this box to dismiss)

how long before I get tag badges?

Philosophy Meta

Q&A about the site for those interested in the study of the fundamental nature of knowledge, reality, and existence

-- How many upvotes do I have for each tag?
-- how long before I get tag badges?

DECLARE @UserId int = ##UserId##

--    TagName,
--    COUNT(*) AS UpVotes 
--FROM Tags
--    INNER JOIN PostTags ON PostTags.TagId =
--    INNER JOIN Posts ON Posts.ParentId = PostTags.PostId
    --INNER JOIN Votes ON Votes.PostId = Posts.Id and VoteTypeId = 2
--    Posts.OwnerUserId = @UserId

--GROUP BY TagName 

--select * From Posts where Posts.PostTypeId = 1 and 2 IN Posts.Tags

--SELECT TagName, COUNT(*) AS Questions 
--FROM Tags
--INNER JOIN PostTags ON PostTags.TagId = Tags.Id
--INNER JOIN Posts ON Posts.ParentId = PostTags.PostId
--WHERE Posts.PostTypeId = 1
--GROUP BY TagName
--ORDER BY Questions DESC

--declare @VoteStats table (PostId int, up int, down int, CreationDate datetime)
--insert @VoteStats
--    p.Id,
--    up = sum(case when VoteTypeId = 2 then
--        case when p.ParentId is null then 5 else 10 end
--        else 0 end),
--    down = sum(case when VoteTypeId = 3 then 2 else 0 end),
--    p.CreationDate
--from Votes v join posts p on v.postid =
--where v.VoteTypeId in (2,3)
--and OwnerUserId = @UserId
--and p.CommunityOwnedDate is null
--and datediff(day, p.CreationDate, v.CreationDate) > @ignoreDays
--and datediff(day, p.CreationDate, @latestDate) > @minAgeDays
--group by p.Id, p.CreationDate, p.ParentId

set nocount on

declare @topTags table (id int, name nvarchar(35), questionCount int)
insert @topTags
select top 40 Id, TagName, Count from Tags order by Count desc

set nocount off

select name, SUM(Posts.Score) as score 
from @topTags
    inner join PostTags on PostTags.TagId = id
    inner join Posts on Posts.ParentId = PostTags.PostId
    Posts.OwnerUserId = @UserId
group by name 
--order by score desc

Enter Parameters

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