Count Results for multiple choice

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaxkookie
    New Member
    • Sep 2009
    • 1

    Count Results for multiple choice

    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:
    [code=oracle]

    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE < 1 THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS NO_ANS,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '1' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS1_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '1' THEN V_ASSESSMENTREP ORT.ANSWER_TEXT END AS ANS1_TEXT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '2' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS2_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '3' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS3_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '4' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS4_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '5' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS5_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '6' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS6_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '7' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS7_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '8' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS8_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '9' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS9_COUNT
    [/code]

    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.
    Last edited by amitpatel66; Sep 23 '09, 10:06 AM. Reason: added code tags
  • OraMaster
    New Member
    • Aug 2009
    • 135

    #2
    Originally posted by jaxkookie
    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.ANS WER_SEQUENCE < 1 THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS NO_ANS,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '1' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS1_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '1' THEN V_ASSESSMENTREP ORT.ANSWER_TEXT END AS ANS1_TEXT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '2' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS2_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '3' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS3_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '4' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS4_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '5' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS5_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '6' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS6_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '7' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS7_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '8' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) END AS ANS8_COUNT,
    CASE WHEN ANSWER_BANK.ANS WER_SEQUENCE = '9' THEN COUNT(ANSWER_BA NK.ANSWER_SEQUE NCE) 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

    Comment

    Working...