Most recent edits (posthistory items) on the question and all answers

1

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers Meta

Q&A about the site for Drupal developers and administrators

;  with recentedits_cte as (
SELECT
  MAX(ph.Id) AS phid
FROM PostHistory ph INNER JOIN Posts p ON p.Id=ph.PostId
WHERE (coalesce(p.parentid, p.id)=##qid?13750##)
  AND ph.PostHistoryTypeId IN (##list?1,2,3,4,5,6,7,8,9##)
GROUP BY p.Id
)

SELECT  
  CASE p.PostTypeId
   WHEN 1 THEN 'Question'
   WHEN 2 THEN 'Answer'
  END,
  ph.PostId AS [Post Link],
  concat('site://posts/', ph.PostId,'/revisions') AS [Revisions],
  ph.CreationDate, ph.UserId AS [User Link],
  ph.Comment
FROM recentedits_cte r INNER JOIN PostHistory ph ON ph.Id=r.phid
  INNER JOIN Posts p On p.Id=ph.PostId
ORDER BY ph.CreationDate DESC

Enter Parameters

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