DECLARE @Score AS INT = 25 --##Score## DECLARE @Mo...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @Score        AS INT = 25 --##Score##
DECLARE @Months       AS INT = 6 --##Months##
DECLARE @QuestionDate AS DATETIME2 = DATEADD( MONTH, -(@Months + 6), GETDATE() )
    
SELECT TOP 3000
    --COUNT(*)                  AS TotalCount
    Answers.Id                AS [Post Link]
    
FROM
  Posts                       AS Questions
  WITH                        ( NOLOCK )
  
  INNER JOIN
  Posts                       AS Answers
  WITH                        ( NOLOCK )
  ON Questions.Id             = Answers.ParentId
  
WHERE
      Questions.PostTypeId         = 1 -- questions
  AND Questions.CreationDate       < @QuestionDate
  AND Questions.ClosedDate         IS NULL
  AND Questions.CommunityOwnedDate IS NULL
  AND Answers.CreationDate         >= DATEADD( MONTH, @Months, Questions.CreationDate )
  AND Answers.Score                >= @Score

OPTION
  ( FORCE ORDER, LOOP JOIN, MAXDOP 1 )

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results