WITH SUBTABLE AS ( SELECT PostHistory.* , SUBSTRING(TEXT,...

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

WITH SUBTABLE AS ( SELECT PostHistory.*
, SUBSTRING(TEXT,25,CHARINDEX(']',TEXT,25)-25) AS DuplicateQuestionId
FROM PostHistory
WHERE PostHistoryTypeId = 10
AND CreationDate BETWEEN '2012-07-01' AND '2012-12-31'
AND TEXT LIKE '{"Original%'
AND CHARINDEX(',', SUBSTRING(TEXT,25,CHARINDEX(']',TEXT,25)-25) ) = 0
)
SELECT *
FROM SUBTABLE
WHERE EXISTS (
SELECT 0 
FROM Posts 
WHERE CAST( PostId AS varchar(30) ) = DuplicateQuestionId
AND NOT ClosedDate IS NULL
)

Enter Parameters

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