74

While reading the tag info, I accidentally discover that I am listed in the 5 Top Answerers.

enter image description here

Question

Is there a way to know what are the tags that I am listed in the Top 5 Answerers? Also how can I list these (tags + positions) in the About me section?

6

1 Answer 1

108

With the use of SEDE (short for The Stack Exchange Data Explorer, tutorial) and some SQL fu the following query gives you roughly what you're looking for:

-- userid: User Id "The id in the url of your Stack Oveflow user profile"
-- pos: Top position "What is the position you're interested in"

-- create a temp table to hold only the tagid's for the OP
-- this should reduce from 80,000 rows to join to way less.
create table #tags(id integer primary key
                  , tagname nvarchar(35)
                  )
                  
insert into #tags
select distinct 
       t.id
     , t.tagname
from tags t
inner join posttags pt on pt.tagid = t.id
inner join posts p on pt.postid = coalesce(p.parentid, p.id)
where p.owneruserid = ##userid## 


;with top_answerers as (
select a.owneruserid
     , t.tagname 
     , sum(a.score) [tag score]
     , rank() over(partition by t.tagname order by sum(a.score) desc ) as pos
from posts a
inner join posttags pt on pt.postid = a.parentid
inner join #tags t on t.id = pt.tagid -- join on the tags temp table
where a.posttypeid = 2 -- answer
and a.owneruserid is not null 
group by a.owneruserid
       , t.tagname
)

select tagname
     , pos
     , owneruserid as [User Link]
     , [tag score]
from top_answerers
where  owneruserid = ##userid?7031230##
and pos <= ##pos?10##
order by pos desc

You need to provide your user id (found in the url of your profile) and a top position, that indicates if you want to see the tags where you are in the top 5, the top 10 or top 100.

Above query does the heavy lifting in the CTE top_answerers by joining the answers in the posts table with the questions in the posts table and joining that via posttags to the tags table. The result is then grouped by user and tagname so we can get the sum of the answer score. By partitioning over tagname and ordering by the sum of scores we get all users rank for that tag.
The main query only needs to limit the results to the user we're interested in and up to which position to include in the final result.

Keep in mind that SEDE is only updated once a week, on Sunday so the result of the query might not reflect your current rank.

When run today this is the result:

A resultset for user Hadi, showing tag ssis-2008 for them as position 8

Unfortunately you can't have this automatically update in your profile as the about me box doesn't allow for running scripts. At best you could host an image on a server you control and then write some parsing code to update the image once a week on your server. I leave that for the reader to implement.

19
  • 11
    Thanks for writing this script. It was actually quiet interesting to see what results I go for my username. Apparently I am one of the top answers for the bungeecord tag, when I've never even heard of bungeecord. It seems like I once answered a java questions that had extra tags. Now I'm wondering if those extra tags should be removed.
    – Tot Zam
    Commented Jun 18, 2017 at 18:46
  • 1
    @TotZam Glad this query gives you all kind of insights and starting points to improve posts. Enjoy!
    – rene
    Commented Jun 18, 2017 at 18:57
  • 3
    I tried to run this for me using the preset value of 10 for "top position", but I got some kind of fatal error. I guess my awesomeness caused an overflow. So I dropped the value down to 5, and promptly learned that I am the #1 answerer for the application-name tag. :-/
    – Cody Gray Mod
    Commented Jun 19, 2017 at 10:15
  • 3
    I totally confirm your awesomeness @CodyGray although I'm a bit disappointed you're not a gold badge holder in said tag ...
    – rene
    Commented Jun 19, 2017 at 10:28
  • 7
    @rene Smaller tags get way less attention, views and votes, making it many times almost impossible to get a gold badge. I actually think this is a flaw in the gold badge privilege system, since you can have a group of users who are experts in certain tags, yet have no one who has the ability to dupe close obviously duplicate questions. I've spent some times in some smaller tags, and I'm lucky if I even get 1 vote per post, since the posts have very low traffic and are more often than not asked by new users.
    – Tot Zam
    Commented Jun 19, 2017 at 14:05
  • I'm in the top-10 for... [QVector3d] and [jQuery-nestable] (scores of 0 and 2, respectively). Go me. Also neat query. I love seeing SEDE usage, even if my SQL is not...strong enough to write my own queries (I only know enough SQL to be dangerous). Commented Jun 19, 2017 at 21:09
  • 2
    @Draco18s did you give the tutorial a try?
    – rene
    Commented Jun 19, 2017 at 21:10
  • @rene I haven't :) But I don't have a need either. I don't have any burning statistics I want to know, I just see other people posting queries and go "oh neat, I wonder what that query returns for me." Usually comes up in a Code Golf situation ("write short code that does X query on Y user(s)"). The SQL quip is just me being a smartass. ;) Commented Jun 19, 2017 at 21:14
  • 4
    Awesome burnination target query you've got there, rene ;) Commented Jun 19, 2017 at 21:20
  • That's disappointing - the only tag I'm in the top ten for is ora-00917 - there's a whole bunch of these ora-xxxxx tags for Oracle errors that may or may not be burninateable.
    – Ken Y-N
    Commented Jun 21, 2017 at 0:16
  • Just ran this query on my Worldbuilding profile. In order of increasing rank, [Chemistry], [Data Storage], and [lava.] That's right, I'm the #2 top answerer on [lava] with a score of 22. I'm also #19 for [blood]. I'm on a watch list now, for sure. Commented Jun 22, 2017 at 16:32
  • I didn't intent to write queries that give you the shivers @Draco18s ...
    – rene
    Commented Jun 22, 2017 at 16:37
  • @rene Actually, the blood one should be higher because this question isn't tagged with [blood] and my answer is top, at +55. :worry: (So I'm not really surprised :P ) Commented Jun 22, 2017 at 16:39
  • Any way to speed up this query? It used to work but now I get "Execution Timeout Expired. The timeout period elapsed prior to completion of the operation..." maybe the dump has too much data now?
    – wim
    Commented Aug 8, 2019 at 22:08
  • @wim what value for pos did you try and did you try for your account? I'll see in the weekend if I can apply a tweak.
    – rene
    Commented Aug 9, 2019 at 7:06

You must log in to answer this question.

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