Percent of Questions Accepted and Answered to Total Questions

0

Please login or register to vote for this query.

(click on this box to dismiss)

This was written in an attempt to provide stats for this: http://www.reddit.com/r/Wordpress/comments/ljlsy/what_do_you_guys_think_of/ I'm not 100% sure this is correct, but I'm pretty sure it is close. Would love it if someone who knows the schema better can review it.

Anime and Manga

Q&A for anime and manga fans

-- Percent of Questions Accepted and Answered to Total Questions
-- This was written in an attempt to provide stats for this: 
-- http://www.reddit.com/r/Wordpress/comments/ljlsy/what_do_you_guys_think_of/
-- I'm not 100% sure this is correct, but I'm pretty sure it is close. 
-- Would love it if someone who knows the schema better can review it.

select 
    Questions,
    Accepted,
    Answered,
    cast( Questions - Answered as int ) as Unanswered,
    cast( cast( Accepted/Questions*100 as decimal(5,1) ) as varchar(5) ) +'%' as PercentAccepted,
    cast( cast( Answered/Questions*100 as decimal(5,1) ) as varchar(5) ) +'%' as PercentAnswered
from (
select
    count(*)*1.0 as Questions,
    sum(case when AcceptedAnswerId is null then 0 else 1 end)*1.0 as Accepted,
    sum(case when ISNULL(AnswerCount,0)=0 then 0 else 1 end)*1.0 as Answered
from
   Posts 
where 1=1
   and PostTypeId=1
   and ClosedDate IS NULL 
   and CommunityOwnedDate IS NULL
) x

Enter Parameters

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