Get the number of times a user edited their own posts

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow на русском Meta

Вопросы и ответы о сайте для программистов

declare @UserId int = ##UserId?584676##
declare @UrlBase nvarchar(50) = 'https://stackoverflow.com/questions/'

select coalesce(post.Title, parent.Title) as QuestionTitle,
  Count(*) as Edits,
  post.PostTypeId as PostType,
  @UrlBase + cast(h.PostId as nvarchar(25)) + '|' + cast(h.PostId as nvarchar(25)) as PostId
from Posts post
  inner join PostHistory h
    on post.PostTypeId in(1, 2) and post.Id = h.PostId
  inner join Posts parent
    on parent.Id = post.ParentId
  where h.UserId = @UserId and h.PostHistoryTypeId in(4, 5, 6)
  group by h.PostId,
    post.Title,
    parent.Title,
    post.PostTypeId
order by Edits desc;

Enter Parameters

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