Q&A for professional and enthusiast programmers
-- Percentage of questions with accepted answers, based on tags.
with totals as(
select top 200
t.TagName as 'Tag',
count(*) as 'TotalQuestion',
count(p.AcceptedAnswerId) as 'TotalAccepted'
from Posts p
join PostTags pt on pt.PostId = p.id
join Tags t on pt.TagId = t.id
group by t.id, t.TagName
order by TotalQuestion desc
select *, round(100 * TotalAccepted/TotalQuestion, 2) as 'Percentage' from totals
--where totals.TotalQuestion > 2000
order by Percentage desc