Q&A for practitioners, researchers, and students in cognitive science, psychology, neuroscience, and psychiatry
DECLARE @User int SELECT @user = 23199 select top 25 tagname , count(*) from posts as p inner join posttags as pt on pt.postid = p.id inner join tags as t on t.id = pt.tagid where (p.owneruserid = @user and p.posttypeid = 1) OR P.ID IN ( SELECT ParentID FROM Posts WHERE p.posttypeid = 2 AND p.owneruserid = @user ) group by tagname order by 2 desc --select * from posts where owneruserid = 23199