473,378 Members | 1,699 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,378 software developers and data experts.

AND query in survey table

Hi!

I have the following table:

id, questions, answers
1,q1,1
2,q1,5
1,q3,2
3,q1,3
4,q1,5
1,q2,2
2,q3,1
2,q2,1
etc

If I need to count together all the possible answers to q1 OR q2 then
I use the following query:

SELECT answers, count(answers) FROM table WHERE questions = q1 OR
questions = q2 GROUP BY answers;

But how the query looks like if I want to count all the possible
answers ONLY in those cases where answers to q1 AND q2 are the same?

Please advice.
Nov 13 '05 #1
1 1299

Do you mean

SELECT table.answers, Count(table.answers) AS CountOfAnswers
FROM table INNER JOIN table AS table_1 ON table.answers = table_1.answers
GROUP BY table.queestions, table_1.questions, table.answers
HAVING (((table.questions)="q1") AND ((table_1.questions)="q2"));

?
Bas Hartkamp

"Abhi" <go****@megadelfi.com> wrote in message
news:1d**************************@posting.google.c om...
Hi!

I have the following table:

id, questions, answers
1,q1,1
2,q1,5
1,q3,2
3,q1,3
4,q1,5
1,q2,2
2,q3,1
2,q2,1
etc

If I need to count together all the possible answers to q1 OR q2 then
I use the following query:

SELECT answers, count(answers) FROM table WHERE questions = q1 OR
questions = q2 GROUP BY answers;

But how the query looks like if I want to count all the possible
answers ONLY in those cases where answers to q1 AND q2 are the same?

Please advice.

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: GTF | last post by:
PHP Web Survey Idea.. I have been given an opportunity to create a web based survey. This is a fairly lengthy survey of 60 pages on paper (various multiple choice and free form). These are...
5
by: DFS | last post by:
I've written several survey systems in which the majority of the questions have the same or similar responses (Yes/No, True/False, scale of 1 - 5, etc). But this latest survey system I'm working...
1
by: Jon | last post by:
Hi there. I'm trying to create a query (or two) that I can use to produce a spreadsheet but I'm having a bit of trouble. I'm using Access 2000. My db is set up like this: Table1: Intrusive...
2
by: Jwhal | last post by:
I'm having trouble querying one table with multiple entries. I'm not sure if or what kind of joins I need to do this, or if it should be a make table followed by an append, then an update, or what....
0
by: Kaur | last post by:
Hi, I have created a report based on a cross tab query and would like to Sort the column heading of the report based on the sort order of another field. I have three tables called survey...
0
by: Kaur | last post by:
Hi, I have created a report based on a cross tab query and would like to Sort the column heading of the report based on the sort order of another field. I have three tables called survey...
2
by: MJ | last post by:
I am trying to get a parameter query to show me multiple survey #'s or if I click on OK to show me all of the survey #'s. I have tried: Instr(,),. "> 0 or Is Null" is in the criteria but I get...
1
by: jeffro | last post by:
I have a database used for recording survey data. In the database, I have a form that displays a survey participant and a subform that is filled in by selecting a question from a looklist and...
1
by: mcr29 | last post by:
I've been asked to build a survey database. The survey is to be dynamic, allowing any number of questions to be part of the current survey. So I've got a Survey table with SurveyDetail, and a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.