Q&A for serious players and enthusiasts of chess
DECLARE @STARTDATE DATETIME = '2008-01-01' DECLARE @ENDDATE DATETIME = '2008-12-31' SELECT cast(Id as varchar(20))+'<postid>'+Body FROM Posts AS Question where Question.Tags LIKE '%java%' AND Question.Body LIKE '%<code>%' and posttypeid = 1 --and datepart(year,creationdate) = 2008 and 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=Post Closed and d.creationdate BETWEEN @STARTDATE AND @ENDDATE ) order by Id asc