Skip to main content
replaced http://data.stackexchange.com/ with https://data.stackexchange.com/
Source Link

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

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:

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:

much needed performance improvement done
Source Link
rene
  • 42.3k
  • 55
  • 610
  • 777
-- 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 posts q on q.id = a.parentid
inner join posttags pt on pt.postid = qa.idparentid
inner join tags#tags t on t.id = pt.tagid
where a.posttypeid-- =join 2on --the answertags temp table
andwhere qa.posttypeid = 12 -- Questionanswer
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 

enter image description hereA resultset for user Hadi, showing tag ssis-2008 for them as position 8

-- 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"
;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 posts q on q.id = a.parentid
inner join posttags pt on pt.postid = q.id
inner join tags t on t.id = pt.tagid
where a.posttypeid = 2 -- answer
and q.posttypeid = 1 -- Question
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

enter image description here

-- 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 

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

of by one now fixed
Source Link
rene
  • 42.3k
  • 55
  • 610
  • 777

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"
;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 posts q on q.id = a.parentid
inner join posttags pt on pt.postid = q.id
inner join tags t on t.id = pt.tagid
where a.posttypeid = 2 -- answer
and q.posttypeid = 1 -- Question
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:

enter image description here

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.

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"
;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 posts q on q.id = a.parentid
inner join posttags pt on pt.postid = q.id
inner join tags t on t.id = pt.tagid
where a.posttypeid = 2 -- answer
and q.posttypeid = 1 -- Question
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:

enter image description here

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.

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"
;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 posts q on q.id = a.parentid
inner join posttags pt on pt.postid = q.id
inner join tags t on t.id = pt.tagid
where a.posttypeid = 2 -- answer
and q.posttypeid = 1 -- Question
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:

enter image description here

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.

added link to tutoral of SEDE
Source Link
rene
  • 42.3k
  • 55
  • 610
  • 777
Loading
slightly edited to give a bit more context and query explanation
Source Link
rene
  • 42.3k
  • 55
  • 610
  • 777
Loading
Source Link
rene
  • 42.3k
  • 55
  • 610
  • 777
Loading