Q&A for professional and enthusiast programmers
with AcceptedAnswers as ( select a.ParentId QuestionId, a.Id AnswerId, a.OwnerUserId from Posts a where PostTypeId=2 and exists (select 1 from Posts q where q.AcceptedAnswerId=a.Id) ) select Format(count(*)*1.0/(select count(*) from AcceptedAnswers), 'P') PctGoldBadgeAcceptedAnswers from AcceptedAnswers aa where exists (select 1 from PostTags pt join Tags t on t.Id=pt.TagId join Badges b on b.Name=t.TagName and TagBased=1 and Class=1 where pt.PostId=aa.QuestionId and b.UserId=aa.OwnerUserId)