Edit: This computes the score while tag badges are counted by upvotes only. @BalusC's answer should be correct.
Try this query instead, which I forked from that calculates Generalist badge:
-- What is my score for each badge?
-- What is the net non-CW upvote for all tags I have participated?
declare @temp table (id int identity(1,1), TagName char(128), score int);
with answers as (
select score, id, parentId from posts -- find responses of questions
where communityowneddate is null -- which are non-comm-wiki
and posttypeid = 2 -- answers
and owneruserid = ##UserId## -- by you
)
insert @temp(TagName, score)
select t.TagName, sum(a.score) as score from answers a
inner join posttags pt on pt.postid = a.parentId -- find tags of your answers
inner join tags t on pt.tagid = t.id
group by t.tagname
order by score desc
select *, case when score >= 1000 then 'S,G' when score >= 400 then 'S' else '' end from @temp
This shows you still need 47 votes to get a gold badge in [java]
.
(Note that these rare badges may not be handed out immediately when you reach 1,000.)