Combined posthistory (question and all the answers) - only edits

1

Please login or register to vote for this query.

(click on this box to dismiss)

Reverse Engineering Meta

Q&A about the site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation

SELECT
  p.Id, 
  revisions = 'site://posts/' + CAST(p.Id AS varchar)+'/revisions',
  CASE 
    WHEN (p.ParentId IS NULL) 
    THEN 'Question'
    ELSE 'Answer'
  END,
---ph.Id, 
  ph.PostHistoryTypeId,
  CASE ph.PostHistoryTypeId
    WHEN 1 THEN 'Initial Title'
    WHEN 2 THEN 'Initial Body'
    WHEN 3 THEN 'Initial Tags'
    WHEN 4 THEN 'Edit Title'
    WHEN 5 THEN 'Edit Body'
    WHEN 6 THEN 'Edit Tags'
    WHEN 7 THEN 'Initial Title'
    WHEN 8 THEN 'Initial Body'
    WHEN 9 THEN 'Initial Tags'
    WHEN 10 THEN 'Post Closed'
    WHEN 11 THEN 'Post Reopened'
    WHEN 12 THEN 'Post Deleted'
    WHEN 13 THEN 'Post Undeleted'
    WHEN 14 THEN 'Post Locked'
    WHEN 15 THEN 'Post Unlocked'
    WHEN 16 THEN 'Community Owned'
    WHEN 17 THEN 'Post Migrated'
    WHEN 18 THEN 'Question Merged'
    WHEN 19 THEN 'Question Protected'
    WHEN 20 THEN 'Question Unprotected' 
    WHEN 21 THEN 'Post Disassociated'
    WHEN 22 THEN 'Question Unmerged'
    WHEN 24 THEN 'Suggested Edit Applied'
    WHEN 25 THEN 'Post Tweeted'
    WHEN 31 THEN 'Comments moved to chat'
    WHEN 33 THEN 'Post notice added'
    WHEN 34 THEN 'Post notice removed'
    WHEN 35 THEN 'Post migrated away'
    WHEN 36 THEN 'Post migrated here'
    WHEN 37 THEN 'Post merge source'
    WHEN 38 THEN 'Post merge destination'
    WHEN 50 THEN 'Bumped by Community User'
    WHEN 52 THEN 'Question became HNQ'
    WHEN 53 THEN 'Question removed from HNQ by a mod'
  END,
  ph.UserId AS [User Link],
  ph.Comment
FROM PostHistory ph INNER JOIN Posts p ON p.Id=ph.PostId
WHERE coalesce(p.parentid, p.id)=##qid?85211##
---either the post or the parent has this id
  AND (ph.PostHistoryTypeId in (1,2,3,4,5,6,7,8,9))
---only edits  
ORDER BY ph.Id DESC

Enter Parameters

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