User's answers with no downvotes

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

select tmp.id as [Post Link], tmp.upvotes 

from (

    select P.id 
      , sum(
          case V.voteTypeId 
            when 2 then 1 --Upvote
            else 0 
          end) as Upvotes
      , sum(
          case V.voteTypeId
            when 3 then 1
            else 0
          end) as Downvotes

    from Posts P

    join Votes V
    on P.id = V.postId

    where P.ownerUserId = ##userId##
      and P.postTypeId = 2 --answers
    group by P.id

) as tmp
where tmp.downvotes = 0
  
order by tmp.upvotes desc

Enter Parameters

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