Select target questions with changing in their duplicate origins

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

SELECT top 100 pl.PostId AS [Post Link], 
JSON_VALUE(ph.Text, '$.OriginalQuestionIds[0]') AS 'Original duplicate',
pl.RelatedPostId AS 'Current duplicate',
pl.RelatedPostId AS [Post Link]
--SELECT JSON_VALUE(ph.Text, '$.OriginalQuestionIds[0]') AS [Post Link], 
--    pl.RelatedPostId AS [Post Link]
  FROM PostHistory AS ph
  INNER JOIN PostLinks AS pl
    ON pl.PostId = ph.PostId
   AND pl.LinkTypeId = 3 -- duplicate
  INNER JOIN Posts AS p ON p.Id = pl.PostId
  WHERE
    ph.PostHistoryTypeId = 10 -- question closed
    AND ph.Comment = 101 -- as a duplicate
    AND p.Tags like '%python%'
    AND JSON_VALUE(ph.Text, '$.OriginalQuestionIds[0]') != pl.RelatedPostId
  ORDER BY pl.CreationDate DESC

Enter Parameters

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