473,409 Members | 2,056 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,409 software developers and data experts.

Count records in a table

4
I have 2 tables; Course & Questions. This is a basic survey dbase where a course has many surveys. A survey has 10 questions with 4 options to answer from 1 to 4.

I'd like to count the number of options, ie, a tally for different courses....below is an example of how this data must be show;

Course 4 3 2 1
Gender 10 5 4 0
Theatre 5 3 4 2
Behaviour Management 15 10 2 0

mistap
Sep 10 '08 #1
4 1663
aas4mis
97
Please post a more descriptive table layout with your relations between the two tables. With that I should be able to provide a query that may help you out.
Sep 20 '08 #2
mistap
4
Please post a more descriptive table layout with your relations between the two tables. With that I should be able to provide a query that may help you out.
Heres the layout

tb_course has pk_ID, tb_qtns has fk_courseID. Relationship is 1 to many where tb_course has the primary key.

tb_qtns contains questions from 1 to 10 which are number fields, ie, q1, q2, q3 etc.

A course, GENDER e,g has 50 surveys; In a survey, q1 has four options,
1 to 4.

Generally, I'd like a count of the total number of 1s, 2s, 3s, 4s for GENDER

Each course will have a different number of surveys.

Greatly appreciate your help

Mistap
Sep 23 '08 #3
aas4mis
97
Heres the layout

tb_course has pk_ID, tb_qtns has fk_courseID. Relationship is 1 to many where tb_course has the primary key.

tb_qtns contains questions from 1 to 10 which are number fields, ie, q1, q2, q3 etc.

A course, GENDER e,g has 50 surveys; In a survey, q1 has four options,
1 to 4.

Generally, I'd like a count of the total number of 1s, 2s, 3s, 4s for GENDER

Each course will have a different number of surveys.

Greatly appreciate your help

Mistap
Sorry, still a little confused on the layout. If you're wanting the total count of different fields that all correspond to a single parent value (courseID) I believe you're looking for a crosstab. Just open your query editor you can select a crosstab query and use the courseID as your row heading the q's as your column heading (both group by) and possibly sum(q's) as your value [like I said, still a little confused on your table layout.] If you want a tally for each question in a different query that's another option. That would be:
Expand|Select|Wrap|Line Numbers
  1. SELECT c.pk_ID, count(q.q1) FROM tb_course as c INNER JOIN tb_qtns as q on c.pk_id = q.courseID WHERE c.pk_ID = "Gender";
Hope this points you in the right direction.
Sep 23 '08 #4
mistap
4
Sorry, still a little confused on the layout. If you're wanting the total count of different fields that all correspond to a single parent value (courseID) I believe you're looking for a crosstab. Just open your query editor you can select a crosstab query and use the courseID as your row heading the q's as your column heading (both group by) and possibly sum(q's) as your value [like I said, still a little confused on your table layout.] If you want a tally for each question in a different query that's another option. That would be:
Expand|Select|Wrap|Line Numbers
  1. SELECT c.pk_ID, count(q.q1) FROM tb_course as c INNER JOIN tb_qtns as q on c.pk_id = q.courseID WHERE c.pk_ID = "Gender";
Hope this points you in the right direction.

Here's the layout again;

2 tables: one is tb_Courses & the other is tb_qtns with tb_courses being the primary table.

For example, Question 1 has four group option buttons which are 1, 2, 3, 4. If 4 is selected for q1, then, q1 contains 4. If 1 is selected for q2, then, the q2 field contains 1

Heres the problem; i would like to count the total number of ones, twos, etc for each course.

Ive tried crosstab but it doesn't seem to work
Sep 29 '08 #5

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

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
6
by: John | last post by:
I've got a single table I need to query to return records that have no "related records." Table dataset example: 1. John, Biology 2. Dave, Math 3. Susan, Biology 4. Betty, Sociology The...
0
by: DataFreakFromUtah | last post by:
Hello! No question here, just a procedure for the archive. Search critera: count records imported count data imported count number of rows imported count number of records imported record import...
2
by: Lauren Quantrell | last post by:
I am using a stored procedure as the recordsource on an MS-Access2000 form: Forms!frmName.RecordSource = "dbo.myStoredProcedure" The stored procedure creates a temp table #Contacts and then...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
4
by: Anuradha | last post by:
Dear Experts How can I count records in a data reader? Thx Anuradha
2
by: rn5a | last post by:
A SQL Server 2005 stored procedure expects a parameter 'UserID' depending upon which it retrieves the no. of records & OrderIDs corresponding to the 'UserID' from a DB table (note that OrderID &...
9
by: MLH | last post by:
A mailing list table in its virgin state contained sequential, consecutive integers in an autonumber field (A97). I've deleted records throughout the table. Now I would like to identify each...
6
markrawlingson
by: markrawlingson | last post by:
Hopefully someone can help me out with this, it's driving me nuts... I have two tables - We'll call them table1 and table2. Table1 holds event information, and table2 holds user registration data...
12
by: petter | last post by:
Hi! I have two questions: one question that regards the COUNT-function, and one about how to display a month even if I don’t have any data for that month. I have an Access database where I want...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.