Connecting Tech Pros Worldwide Forums | Help | Site Map

Count Results for multiple choice

Newbie
 
Join Date: Sep 2009
Posts: 1
#1: Sep 18 '09
I have been trying to count each answer for each question and roll this up to one line item per question with totals for each answer. what I am getting is staggered answers. example, question 1 has 9 possible answers. I get the count for each, but question 1 is repeated 9 times. here is the part of the code I get the stagger results with:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE < 1 THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END  AS NO_ANS,
  3.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '1' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS1_COUNT,
  4.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '1' THEN V_ASSESSMENTREPORT.ANSWER_TEXT  END  AS ANS1_TEXT,
  5.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '2' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS2_COUNT,
  6.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '3' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS3_COUNT,
  7.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '4' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS4_COUNT,
  8.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '5' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS5_COUNT,
  9.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '6' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS6_COUNT,
  10.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '7' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS7_COUNT,
  11.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '8' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS8_COUNT,
  12.  CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '9' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE)  END  AS ANS9_COUNT
  13.  
I just want one line item per question and a total count for each answer. I also need to know how to count the blank responses.

OraMaster's Avatar
Member
 
Join Date: Aug 2009
Location: Pune, India
Posts: 76
#2: Sep 23 '09

re: Count Results for multiple choice


Quote:

Originally Posted by jaxkookie View Post

I have been trying to count each answer for each question and roll this up to one line item per question with totals for each answer. what I am getting is staggered answers. example, question 1 has 9 possible answers. I get the count for each, but question 1 is repeated 9 times. here is the part of the code I get the stagger results with:
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE < 1 THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS NO_ANS,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '1' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS1_COUNT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '1' THEN V_ASSESSMENTREPORT.ANSWER_TEXT END AS ANS1_TEXT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '2' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS2_COUNT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '3' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS3_COUNT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '4' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS4_COUNT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '5' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS5_COUNT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '6' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS6_COUNT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '7' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS7_COUNT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '8' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS8_COUNT,
CASE WHEN ANSWER_BANK.ANSWER_SEQUENCE = '9' THEN COUNT(ANSWER_BANK.ANSWER_SEQUENCE) END AS ANS9_COUNT

I just want one line item per question and a total count for each answer. I also need to know how to count the blank responses.

Hi

Please post your database table structure, sample data for the same table and the whole query with you are trying to get the result. Also provide how the result u want against the data u'll post. The contents you posted are not sufficient to provide any kind of help to you.
Also use code tags in your future posts thats make easy to read the code :)

Kind Regds,
Bhushan
Reply

Tags
count results, multiple count