;with MultipleDeletes as ( select postid , v.Userid , cou...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

;with MultipleDeletes as
(
select postid
     , v.Userid
     , count(*) [#deleted]
from posthistory
inner join posts p on p.id = postid
cross apply openjson(text, '$.Voters')  with (UserId int '$.Id') v
where posthistorytypeid = 12
and posthistory.userid <> owneruserid -- deleting your own post is fine
and v.userid > 0
group by postid
     , v.Userid
having count(*) > 1
)

select userid as [User Link]
     , count(*)  [# of posts deleted more then once]
     , max([#deleted]) [max deleted on any post]
from MultipleDeletes
group by userid
order by count(*) desc

Enter Parameters

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