Removals of deprecated tags per user

1

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

;  with revisions_cte as
(
SELECT
DISTINCT p.Id AS pid, ph1.Id AS phId
FROM PostHistory ph1 INNER JOIN Posts p ON ph1.PostId=p.Id
WHERE ph1.PostHistoryTypeId in (3,6,9)
  and ((ph1.Text Like '%<##tag1?abstract-algebra##>%') OR (ph1.Text Like '%<##tag2?discrete-mathematics##>%') OR (ph1.Text Like '%<##tag3?geometry##>%') OR (ph1.Text Like '%<##tag4?topology##>%'))
  and NOT((p.Tags Like '%<##tag1##>%') OR (p.Tags Like '%<##tag2##>%') OR (p.Tags Like '%<##tag3##>%') OR (p.Tags Like '%<##tag4##>%'))
), firstrev_cte AS
(SELECT
  pid, MIN(ph2.Id) as MinId
FROM revisions_cte INNER JOIN PostHistory ph2 ON ph2.PostId=pid
  WHERE (ph2.Id>phId)
   AND ph2.PostHistoryTypeId in (3,6,9)
   AND NOT((ph2.Text Like '%<##tag1?abstract-algebra##>%') OR (ph2.Text Like '%<##tag2?discrete-mathematics##>%') OR (ph2.Text Like '%<##tag3?geometry##>%') OR (ph2.Text Like '%<##tag4?topology##>%'))
GROUP BY pid
), users_cte AS
(SELECT PostId AS pid, UserId AS uid, UserDisplayName AS udn
FROM PostHistory INNER JOIN firstrev_cte ON PostHistory.Id=MinId)

SELECT
  COUNT(pid) AS Count, uid AS [User Link], udn
  FROM users_cte
GROUP BY uid, udn
ORDER BY COUNT(pid) DESC

Enter Parameters

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