473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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:
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.
Sep 18 '09 #1
1 2233
OraMaster
135 100+
@jaxkookie
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
Sep 23 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Paul McGuire | last post by:
Well, after 3 days of open polling, the number of additional votes have dropped off pretty dramatically. Here are the results so far: Total voters: 55 (with 3 votes each) Votes for each choice...
9
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using...
10
by: Henk Ernst Blok | last post by:
Hi Posgres users/developers, Can anyone explain why PosgreSQL (version 7.4.5 on Linux) does a full table scan to compute a count(*) on a base table after a vacuum analyze has been done with no...
1
by: andrea | last post by:
I need to get the child of parent/child relation and I've some perplexity about the best method to use. The classic (select count(*) id from table where id = a.parentid) nested into a select...
2
by: jonathan184 | last post by:
Hi I am having a problme where the results of the sql count is not matching the results of the perl script sql count. The script was working fine up till Wed last week and after that the results...
5
by: whitsey | last post by:
Here is what I have: SELECT (SELECT COUNT(*) AS SEARCHES FROM SEARCHES INNER JOIN GROUPS ON SEARCHES.SITE_ID = GROUPS.SITE_ID WHERE
10
hyperpau
by: hyperpau | last post by:
I've been going nuts about it and I've been searching all over the forums to find answers. Can somebody please help me? I am a somehow advanced Access user with basic VBA knowledge. (No ADO or...
10
aas4mis
by: aas4mis | last post by:
I have a form with an unbound field as my lookup. Private Sub txtToShip_AfterUpdate() Dim strFilter As String strFilter = " like " & Chr$(39) & "*" & Forms!frmDataEntry!txtToShip...
9
by: NvrBst | last post by:
Whats the best way to count the lines? I'm using the following code at the moment: public long GetNumberOfLines(string fileName) { int buffSize = 65536; int streamSize = 65536; long...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.