Func 1

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

select v.creationdate
     , count(*)  [Total]
     , sum(case when votetypeid = 2 then 1 else 0 end) [upvotes]
     , sum(case when votetypeid = 3 then 1 else 0 end) [downvotes]
     , sum(case when votetypeid = 2 and posttypeid = 1 then 1 else 0 end) [Q - upvotes]
     , sum(case when votetypeid = 3 and posttypeid = 1 then 1 else 0 end) [Q - downvotes]
     , sum(case when votetypeid = 2 and posttypeid = 2 then 1 else 0 end) [A - upvotes]
     , sum(case when votetypeid = 3 and posttypeid = 2 then 1 else 0 end) [A - downvotes]
from votes v
inner join posts p on p.id = v.postid and posttypeid in (1,2) -- Q, A
where v.votetypeid in (2,3) -- Up, Down
group by v.creationdate
order by v.creationdate desc

Enter Parameters

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