DECLARE @STARTDATE DATETIME = 2008 --'2015-11-01 00:00:00';

0

Please login or register to vote for this query.

(click on this box to dismiss)

Audio-Video Production Meta

Q&A about the site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation

DECLARE @STARTDATE DATETIME = 2008 --'2015-11-01 00:00:00';
DECLARE @ENDDATE DATETIME = 2018--'2015-12-31 23:59:59';
DECLARE @NewLineChar AS CHAR(2) = CHAR(13);
declare @varDATE int = 2018;

-- 03-31, 05-31, 07-31, 08-31, 10-31, 12-31
with cteQuestions (id, AcceptedAnswerId) as (
SELECT id, AcceptedAnswerId  FROM 
  Posts AS Question 
  where    
  Question.Tags LIKE '%java%' AND 
  --Question.Body LIKE '%<code>%' and 
  posttypeid = 1 
  and Year(question.creationdate) BETWEEN @STARTDATE AND @ENDDATE
  and AcceptedAnswerId  is not null
  --and id = 18731465 
  and id not in (
  SELECT d.id
  FROM Posts d  -- d=duplicate
    LEFT JOIN PostHistory ph ON ph.PostId = d.Id
    LEFT JOIN PostLinks pl ON pl.PostId = d.Id
    LEFT JOIN Posts o ON o.Id = pl.RelatedPostId  -- o=original
  WHERE
    d.PostTypeId = 1  -- 1=Question
    AND pl.LinkTypeId = 3  -- 3=duplicate
    AND ph.PostHistoryTypeId = 10  -- 10 = vote Close the Post
    and datepart(year,d.creationdate) <= @varDATE
  )
)
select count(*)  
from  posts answeres
inner join ctequestions questions
on answeres.id = questions.AcceptedAnswerId 
--and  answeres.posttypeid = 2
where 
datepart(year,answeres.creationdate) <= @varDATE

Enter Parameters

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