SELECT * FROM Posts p INNER JOIN PostHistory ph ON p.Id =...

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 *
FROM Posts p
INNER JOIN PostHistory ph ON p.Id = ph.PostId
WHERE ph.PostHistoryTypeId IN (4,5)
AND ph.UserID = 1248365
AND DATEADD(MONTH, -6, ph.CreationDate) > ALL (
    SELECT pph.CreationDate FROM PostHistory pph WHERE (
      ph.PostID = pph.PostID AND
      ph.CreationDate > pph.CreationDate
    )
  )
AND p.OwnerUserId != 1248365
order by p.id

Enter Parameters

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