Please login or register to vote for this query.

(click on this box to dismiss)

Joomla Meta

Q&A about the site for Joomla! administrators, users, developers and designers

select b.Years, b.Groups AcceptedAnswerGroup,
sum(b.HowManyQuestion) AcceptedAnswerNoOfQuestions,
--yearlytotal = (select count(*) from posts where AcceptedAnswerId is not null and year(creationdate) = b.Years)
cast(round((sum(b.HowManyQuestion)/cast(1062902 as float)*100 ),2) as NUMERIC(15,2)) FirstPercentage
from (
	 select a.Years, 
	WHEN a.ResponseInDays between  0 and 0 then 00
	WHEN a.ResponseInDays between 1 AND 10 THEN 0110 
										  WHEN a.ResponseInDays between 11 AND 30 THEN 1130
										  WHEN a.ResponseInDays between 31 AND 90 THEN 3190
										  WHEN a.ResponseInDays between 91 AND 180 THEN 91180 
										  ELSE 181000
										  END as Groups, a.ResponseInDays, sum(HowManyQuestion) HowManyQuestion from (

									SELECT datepart(year,question.creationdate) Years,
									DATEDIFF(day, question.creationdate, asnswer.creationdate) ResponseInDays,
									count(*) HowManyQuestion
									FROM posts question
									inner join posts asnswer
									on question.AcceptedAnswerId = asnswer.id
	where datepart(year,question.creationdate) = 2016
									and DATEDIFF(day, question.creationdate, asnswer.creationdate) >= 0
									group by datepart(year,question.creationdate),
									DATEDIFF(day, question.creationdate, asnswer.creationdate)
									) a 
									group by a.Years, a.ResponseInDays
					) b 
					group by b.Years,b.Groups
					order by b.Years,b.Groups

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results