... to balance the requests that ask to do something about down votes
Q&A for linguists, teachers and students of the Korean language
select eomonth(votes.creationdate) , sum(case when votetypeid = 1 then 1 else 0 end) accept , sum(case when votetypeid = 3 then 1 else 0 end) down , sum(case when votetypeid = 2 and posttypeid = 1 then 1 else 0 end) [Q-up] , sum(case when votetypeid = 3 and posttypeid = 1 then 1 else 0 end) [Q-down] , sum(case when votetypeid = 2 and posttypeid = 2 then 1 else 0 end) [A-up] , sum(case when votetypeid = 3 and posttypeid = 2 then 1 else 0 end) [A-down] from votes inner join posts p on p.id = votes.postid where votetypeid in (1,2,3) and posttypeid in (1,2) and votes.creationdate <= eomonth(dateadd(m, -1, getdate())) group by eomonth(votes.creationdate) having eomonth(votes.creationdate) >= '2024-01-01' order by 1