6

I think in Stack Exchange profile, top tags sorted by all reputation (answers reputation + questions reputation). But we could see only the answer reputation for each tag on the profile page or tag page.
However, in the SO mobile app, we could see all reputation top tags in our home profile.
So, I decided to run a query in the data.StackExcange to get something like that, but I didn't succeed.

Here's my query:

select p.OwnerUserId as [User Link]
     , sum(p.score) as post_repuation 
from posts p
inner join posts q on q.id = p.parentid
where p.OwnerUserId = ##userid?3702377##
-- and p.posttypeid = 2 -- answers
and q.tags like '%##TAG##%'
group by p.OwnerUserId

2 Answers 2

5

This query sums your reputation over all posts for a specific tag:

select p.OwnerUserId as [User Link]
     , sum(p.score) as post_repuation 
from posts p
inner join posttags pt on pt.postid = coalesce(p.parentid, p.id)
inner join tags t on t.id = pt.tagid
where p.OwnerUserId = ##userid?3702377##
-- and p.posttypeid = 2 -- answers
and t.tagname = ##TAG:string##
group by p.OwnerUserId

I have chosen here to join on posttags and tags to prevent a full table scan over the massive posts table. Note that only questions have tags, so the coalesce trick makes sure posttags is joined on the question or on the parent of an answer.

Keep in mind SEDE is only updated once a week, on Sunday 03:00 UTC.

0
1

I modified the query given in rene's answer to ignore users, and count only reputation for answers for given tag, to get to the new query Collective answer reputation for tag:

select ##TAG:string##, sum(p.score)
from posts p
inner join posttags pt on pt.postid = p.parentid
inner join tags t on t.id = pt.tagid
where p.PostTypeId = 2 and t.tagname = ##TAG:string##

I didn't analyze the database structure in depth but the results seem quite convincing:

For the example comparison (see linked Accumulated reputation for tags) we get:

  • django: 978,840

  • flask: 143,247

today (2021-01-20).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .