Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Percentage pass calculation

Author  Topic 

j4ydh
Starting Member

18 Posts

Posted - 2012-01-13 : 12:26:15
Hi

I am trying to form a statement that can look at results saved in a table currently as bit (1) when answer is correct.

so if out of 10 possible questions if 9 are correct the percentage calculation would return greater than 80% representing a pass that could be recorded.

If there is a road map or information that would help it would be appreciated.

Thank you in advance
J

FischMan2
Yak Posting Veteran

59 Posts

Posted - 2012-01-13 : 12:38:41
How do you know that 80% is a pass? Is it hardcoded, or being pulled from a table somewhere?

Some psuedo-code (this won't work, but might give you an idea):

select c.studentid, cast(c.numcorrect > 0.8 as bit) as IsPassing from (
select b.studentid, (b.numcorrect / b.numtotalanswer) as percentcorrect from (
select a.studentid, sum(a.IsCorrect) as NumCorrect, a.numtotalanswers from StudentAnswers a where something = something
group by a.studentid, a.numtotalanswers) b
) c


FischMan
Go to Top of Page
   

- Advertisement -