select (case when p.posttypeid = 1 then 'Question' when p...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu Meta

Q&A about the site for Ubuntu users and developers

select
 (case 
  when p.posttypeid = 1 then 'Question'
  when p.posttypeid = 2 then 'Answer'
end) as Type,
(case
  when v.votetypeid = 2 then 'Up Vote'
  when v.votetypeid = 3 then 'Down Vote'
end) as Direction, 
count(*) As Votes
from votes v join posts p on v.postid = p.id
where v.votetypeid in (2,3)
group by p.posttypeid, v.votetypeid

Enter Parameters

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