p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   Survey Question! (http://p2p.wrox.com/showthread.php?t=11646)

NeedASP April 9th, 2004 12:59 PM

Survey Question!
 
Dear experts,

My survey has somewhat 50 questions.
Each question has 6 multiple choices answers.
These choices are the same for all 50 questions.
Fx:
Q1. How do you rate your company performance?
a. Excellent
b. Very good
c. Good
d. Not very good
e. Very bad
d. N/A


2. How do you rate this article?
a. Excellent
b. Very good
c. Good
d. Not very good
e. Very bad
d. N/A

and so on.

Requirement #1: Display the total voted for each answer for each question. This is done.
Here is an example of what the result looks like:

Q1. How do you rate your company performance? 120
               Total voted Percentage
a. Excellent 35 21.17%
b. Very good 20 16.67%
c. Good 5 4.17%
d. Not very good 10 8.33%
e. Very bad 30 25%
d. N/A 20 16.67%
               ===== =====
                120 100%
Requirement #2: Display the total voted for all choices except 'N/A' choice. This is done too.

Here is an example of what the result looks like:

Q1. How do you rate your company performance? 120
               Total voted Percentage
a. Excellent 35 21.17%
b. Very good 20 16.67%
c. Good 5 4.17%
d. Not very good 10 8.33%
e. Very bad 30 25%
                ===== ====
                100 100%
I just used a WHERE clause to remove the last choice 'N/A'
and re-calculate the numbers a bit.

Requirement #3: Display the total voted for all choices except 'N/A' with this format: (And this is NOT done).

Q1. How do you rate your company performance? 120
               Total voted Percentage
a. Very good 55 55%
b. OK 5 5%
c. Bad 40 40%
               ===== ====
                100 100%

55 (35 + 25). They want to combine 'Excellent' and 'Very good'
5. THey want to leave this one alone
40 (30+ 10). They want to combine 'Not very good' and 'Very bad'

Does anyone have any idea on how this could be done?

This is my logic but I am not sure this is the best option:

1. Hard code the choices: 'Very good', 'OK' and 'Bad' insteads of populating them from db using a Loop. Also, note that the choice 'OK' is what they come up with insteads of 'Good'.

2. Write an SQL query to calculate the sum of 'Excellent' and 'Very good' to make up the 'Very good' choice. Something like,
SELECT SUM(ResultsTable.total) AS Very good
FROM ResultsTable INNER JOIN
             AnswersTable ON ResultsTable.AnswersTableID = answers.AnswersTableID
WHERE (answersTable.answerdesrcription = 'Excellent' OR
                      answersTable.answersdescription = 'Very good') AND (answersTable.QuestionID = 1)

BTW, I have 3 tables: QuestionsTable (store questions), AnswersTable (store answers) and ResultsTable (store the results)

3. Leave the third choice alone (Good) since they don't want to combine with with anything else.

4. Write another SQL Query to combine the last 2 options ('Not very good' and 'Very bad')

5. Write one more Query to sum all the answers except 'N/A' and write some other queries to get the percentages.

I would appreciate if you can share with me some ideas on how this could be done in a simplier way.






All times are GMT -4. The time now is 12:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.