DECLARE @STARTDATE DATETIME = '2018-11-01'; DECLARE @ENDD...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Poker Meta

Q&A about the site for serious players and enthusiasts of poker

DECLARE @STARTDATE DATETIME = '2018-11-01';
DECLARE @ENDDATE DATETIME = '2018-12-31';
declare @varDATE int = 2018;

with cteQuestions (id) as (
SELECT id  FROM 
  Posts AS Question 
  where    
  Question.Tags LIKE '%java%' AND 
  Question.Body LIKE '%<code>%' and 
  posttypeid = 1 
  --and datepart(year,question.creationdate) = @varDATE
  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 datepart(year,d.creationdate) BETWEEN @STARTDATE AND @ENDDATE
  )
)
select cast(answeres.Id as varchar(20))+'<postid>'+answeres.Body  
from  posts answeres
inner join ctequestions questions
on answeres.ParentId = questions.id
where 
--and answeres.creationdate BETWEEN @STARTDATE AND @ENDDATE
 --datepart(year,answeres.creationdate)= @varDATE  and 
answeres.Body LIKE '%<code>%' 
--order by answeres.Id

Enter Parameters

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