Archaeologist Badge advancement

3

Please login or register to vote for this query.

(click on this box to dismiss)

Philosophy Meta

Q&A about the site for those interested in the study of the fundamental nature of knowledge, reality, and existence

-- Archaeologist Badge advancement
-- Retrieve how often you reached the reputation cap

DECLARE @UserId int = ##UserId##

SELECT DISTINCT 
    ROW_NUMBER() OVER (ORDER BY p.Id),
    p.Id AS [Post ID],
    p.ParentId AS [Parent ID],
    CASE WHEN p.ParentId > 0 THEN p.ParentId ELSE p.Id END AS [Post Link]
FROM 
    Posts p 
    INNER JOIN PostHistory ph ON p.Id = ph.PostId
WHERE 
    ph.PostHistoryTypeId IN (4,5)
    AND p.PostTypeId IN (1,2)  
    AND ph.UserID = @UserID
    AND DATEADD(MONTH, -6, ph.CreationDate) > ALL (
        SELECT pph.CreationDate 
        FROM PostHistory pph 
        WHERE ph.PostID = pph.PostID 
        AND ph.CreationDate > pph.CreationDate
    )
GROUP BY
  p.Id, p.ParentId
ORDER BY 
  p.Id DESC

Enter Parameters

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