See all the votes on all my different posts grouped by vote type

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

declare @UserId int = ##UserId##;

with vote_results as (
  select votetypeid, count(*) as "number of votes"
  from posts 
  inner join votes
  on posts.id = votes.postid
  where posts.owneruserid = @Userid
  group by votetypeid
)

select *
from vote_results
inner join
votetypes
on vote_results.votetypeid = votetypes.id
order by id

Enter Parameters

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