aspdotnetuser
Programmer
Hi,
This is probably a simple calculation for SQL experts but I'm still a newbie and not sure how to do the following:
I need to calculate the percentage of people who answered 0 - 7 (out of 10) and the percentage of people who answered 8 - 10 in a quiz. Then I need to subtract the percentage of people who answered 0 - 7 from the percentage of people who answered 8 - 10.
The answers are stored in a table called Answer in a column called AnswerScore, I thought about using [blue]CASE WHEN[/blue] but not sure if this is the correct way to calculate it, here is what I have so far, but if it's wrong can someone help?
[blue](CASE WHEN (answer.answerscore >= '0' AND <= '7') THEN 0-7) AS Answer1[/blue]
Or would I calculate it using a statement similar to this?
[blue](CONVERT(integer,answer.answerscore) / CONVERT(int,answer.answerscore) * 100) AS AnswerSore[/blue]
Can anyone help me with the SQL to caluclate this?
This is probably a simple calculation for SQL experts but I'm still a newbie and not sure how to do the following:
I need to calculate the percentage of people who answered 0 - 7 (out of 10) and the percentage of people who answered 8 - 10 in a quiz. Then I need to subtract the percentage of people who answered 0 - 7 from the percentage of people who answered 8 - 10.
The answers are stored in a table called Answer in a column called AnswerScore, I thought about using [blue]CASE WHEN[/blue] but not sure if this is the correct way to calculate it, here is what I have so far, but if it's wrong can someone help?
[blue](CASE WHEN (answer.answerscore >= '0' AND <= '7') THEN 0-7) AS Answer1[/blue]
Or would I calculate it using a statement similar to this?
[blue](CONVERT(integer,answer.answerscore) / CONVERT(int,answer.answerscore) * 100) AS AnswerSore[/blue]
Can anyone help me with the SQL to caluclate this?