List answers

1

Please login or register to vote for this query.

(click on this box to dismiss)

Check the responses of a specific user, ordered by accepted answers and number of votes.

Stack Overflow

Q&A for professional and enthusiast programmers

-- id: User Identifier
-- minVotes: Minimum Votes

--/*
declare @userId int = ##id:int?107347##;
declare @votes int = ##minVotes:int?0##;

select
  'site://q/' + cast(pp.Id AS nvarchar) + '|' + pp.Title as 'Ask',
  'site://a/' + cast(pr.Id AS nvarchar) + '|' + case when pp.acceptedAnswerid is null then 'No' else 'Yes' end as 'Accepted-Answer',
  pr.Score as 'Votes',
  sum(case when vr.VoteTypeId = 2 then 1 else 0 end) 'Up-Votes',
  sum(case when vr.VoteTypeId = 3 then 1 else 0 end) 'Down-Votes'
from
  Posts pr
  join Posts pp on pp.id = pr.parentid
  left join Votes vr on vr.postId = pr.id and vr.VoteTypeId in(2, 3)
where
  pr.OwnerUserId = @userId
  and pr.Score >= @votes
  and pr.PostTypeId = 2
group by
  pp.Id,
  pr.Id,
  pp.Title,
  pp.acceptedAnswerid,
  pr.Score
order by
  case when pp.acceptedAnswerid is null then 0 else 1 end desc,
  pr.Score desc
--*/

Enter Parameters

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