select sum(case when approvaldate is not null then 1 else...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Computational Science Meta

Q&A for scientists using computers to solve scientific problems

select sum(case when approvaldate is not null then 1 else 0 end) approved
     , sum(case when rejectiondate is not null then 1 else 0 end) rejected
     , count(*) total  
from suggestededits 
where owneruserid is null

select sum(case when approvaldate is not null then 1 else 0 end) approved
     , sum(case when rejectiondate is not null then 1 else 0 end) rejected
     , sum(case when approvaldate is not null 
                 and sev.userid = p.owneruserid 
           then 1 else 0 end) [approved by OP]
     , sum(case when rejectiondate is not null 
                 and sev.userid = p.owneruserid 
           then 1 else 0 end) [rejected by OP]
     , (case votetypeid 
        when 2 then 'Approval' 
        when 3 then 'Reject' 
        else cast(votetypeid as nvarchar) 
        end) as vote
from suggestededits se
inner join suggestededitvotes sev on sev.suggestededitid = se.id
left outer join posts p on se.postid = p.id
where se.owneruserid is null
group by votetypeid 

print '2 votes needed'

select sum(case when approvaldate is not null then 1 else 0 end) approved
     , sum(case when rejectiondate is not null then 1 else 0 end) rejected
     , sum(case when approvaldate is not null 
                 and sev.userid = p.owneruserid 
           then 1 else 0 end) [approved by OP]
     , sum(case when rejectiondate is not null 
                 and sev.userid = p.owneruserid 
           then 1 else 0 end) [rejected by OP]
     , (case votetypeid 
        when 2 then 'Approval' 
        when 3 then 'Reject' 
        else cast(votetypeid as nvarchar) 
        end) as vote
from suggestededits se
inner join suggestededitvotes sev on sev.suggestededitid = se.id
left outer join posts p on se.postid = p.id
where se.owneruserid is null
and se.creationdate > '2017-05-13' -- https://meta.stackoverflow.com/a/349125
group by votetypeid

Enter Parameters

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