DECLARE @UserId int = ##UserId## select distinct v2.post...

7

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserId int = ##UserId##

select distinct v2.postid as 'Own', p2.body as 'Own answer', p2.Score as 'Own score'
from votes v2
inner join posts p2 on p2.id=v2.postid
where 
  p2.posttypeid=2 
  and p2.score>0 
  and p2.CommunityOwnedDate is null 
  and p2.OwnerUserId=@UserId
  and exists (select * from votes v1 inner join posts p1 on p1.id=v1.postid
  where p1.ParentId=p2.ParentId)
--and p1.posttypeid=2 
--  and p1.OwnerUserId<>@UserId  -- redundant
--  and v1.UserId=@UserId
--  and v1.VoteTypeId=1)

Enter Parameters

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