Testing

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

select b.Years, b.Groups,sum(b.HowManyQuestion) numberofQues from (
select a.Years, 
 case 
      WHEN a.ResponseInDays between  0 and 0 then '0-0'
      WHEN a.ResponseInDays between 1 AND 5 THEN '1-5' 
      WHEN a.ResponseInDays between 6 AND 10 THEN '6-10'
      WHEN a.ResponseInDays between 11 AND 20 THEN '11-20'
      WHEN a.ResponseInDays between 21 AND 51 THEN '21-50' 
      WHEN a.ResponseInDays between 51 AND 100 THEN '51-100'
      WHEN a.ResponseInDays between 101 AND 150 THEN '101-150'
      WHEN a.ResponseInDays between 151 AND 200 THEN '151-200'
      WHEN a.ResponseInDays between 201 AND 250 THEN '201-250'
      WHEN a.ResponseInDays between 251 AND 365 THEN '251-365'
      ELSE '366-3677'
      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) <= 2018
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

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