Testing

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

DECLARE @TOTAL INT = 982818
DECLARE @YEAR INT = 2017

select year(questions.CreationDate) Years,t.tagName TagName, count(questions.id) NumQuestions,
(count(questions.id)/cast(@TOTAL as float))*100 as percentage,
cast(round((count(questions.id)/cast(@TOTAL as float)*100 ),2) as NUMERIC(15,2)) percentageRound,
cast(count(questions.id) as varchar(20))+ CHAR(13) + CHAR(10) +'(' 
+cast( cast(round((count(questions.id)/cast(@TOTAL as float)*100 ),2) as NUMERIC(15,2))   as varchar(20))+
'%)' StringPercentatge

from PostTags pt
inner join posts questions 
on  pt.postid = questions.id and questions.posttypeid = 1  
and year(questions.CreationDate) = @YEAR and questions.AcceptedAnswerId is not null
inner join tags t
ON t.Id=pt.TagId and t.tagName in (select top 20 TagName from tags order by count desc)
group by year(questions.CreationDate),t.tagName

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results