Archaeologist Badge - Accurate

2

Please login or register to vote for this query.

(click on this box to dismiss)

Mathematics

Q&A for people studying math at any level and professionals in related fields

DECLARE @UserId INT = ##UserId##;

SELECT COUNT(*)
FROM PostHistory history
INNER JOIN Posts original ON original.Id = history.PostId
WHERE history.UserId = @UserId -- Only count my edits

  -- Only count edits to posts I didn't originate
  AND original.OwnerUserId <> @UserId

  -- Only count standard edits (Edit Title, Edit Body, Edit Tags)
  AND history.PostHistoryTypeId IN (4, 5, 6)
  
  -- Only count edits occurring more than 6 months after a post was created
  AND original.CreationDate < DATEADD(MONTH, -6, history.CreationDate)

  -- Only count edits occurring more than 6 months after any previous edit
  AND NOT EXISTS (
     SELECT TOP (1) *
     FROM PostHistory previous
     WHERE previous.PostId = original.Id 
       AND previous.CreationDate < history.CreationDate
       AND previous.CreationDate > DATEADD(MONTH, -6, history.CreationDate)
  )

Enter Parameters

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