select count(*) [bounties] , sum(case when v.userid = p.o...

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

select count(*) [bounties]
, sum(case when v.userid = p.owneruserid then 1 else 0 end) [own question]
, avg(case when v.userid = p.owneruserid then convert(bigint,u.reputation) else null end) [own avg rep now]
, max(case when v.userid = p.owneruserid then convert(bigint,u.reputation) else null end) [own max rep now]
, sum(case when v.userid = p.owneruserid 
            and p.answercount > 0 then 1 else 0 end) [own Q got Answer]
, sum(case when v.userid = p.owneruserid 
            and p.acceptedanswerid is not null then 1 else 0 end) [own Q got Accepted]
, sum(case when v.userid <> p.owneruserid then 1 else 0 end) [someone else question]
from votes v
inner join posts p on p.id = v.postid
left outer join users u on u.id = p.owneruserid
where votetypeid = 8


select count(*)
from votes v
where votetypeid = 8

Enter Parameters

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