Longest time before the tag was added

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Apps

Q&A for apps, scripts, and development with the Stack Exchange API

with firstrev_cte AS
(
SELECT MIN(ph.Id) AS MinId, p.Id
FROM Posts p JOIN PostHistory ph ON ph.PostId=p.Id
WHERE ph.Text LIKE '%<##tagName?featured##>%'
  AND ph.PostHistoryTypeId in (3,6,9)
GROUP BY p.Id
)

SELECT TOP(##num?100##)
  ph.PostId AS [Post Link],
  url = 'site://posts/' + CAST(ph.PostId AS varchar)+'/revisions',
  ph.UserId AS [User Link], ph.UserDisplayName,
  ph.CreationDate AS [Featured Date],
  p.CreationDate, p.LastActivityDate,
  DATEDIFF(Day, p.CreationDate, ph.CreationDate) AS [Days until tag]
FROM PostHistory ph INNER JOIN firstrev_cte ON ph.Id=MinId
  INNER JOIN Posts p ON ph.PostId=p.Id
ORDER BY  DATEDIFF(Day, p.CreationDate, ph.CreationDate) DESC

Enter Parameters

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