Retrieve count of total no of answers corresponding to each tag at user level

前端 未结 2 1897
太阳男子
太阳男子 2021-01-29 04:08

I am trying to create a query, to find the count of total number of answers (that I have give in stackoverflow) corresponding to each tag.

Through this, I am able to fin

2条回答
  •  面向向阳花
    2021-01-29 04:50

    Below query finds the total number of answers against each tag for a user. It does not consider the self-answered questions of the user, as it can give little additional count.

    --Self answered questions dont count
    select t.TagName, COUNT(q.Id) as countofAnsweredQuestions
    from Posts q
    inner join PostTags AS pt
    ON pt.PostId = q.Id
    inner join Posts a
    on a.parentId = q.Id
    inner join Tags as t
    on pt.tagId = t.Id
    where q.CommunityOwnedDate is null and q.ClosedDate is null 
      and a.OwnerUserId = ##UserId##
      and q.OwnerUserId != ##UserId##
      and a.postTypeId = 2
    GROUP BY t.TagName
    ORDER BY countofAnsweredQuestions desc
    

    I have created permanent link for the query

提交回复
热议问题