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

Get the sum of several records from a table

Hi,

It's my first time to build a database and just learning Access as I
go . I am trying to design a simple database on survey tracking. Here
is my table structure:


tblPerson
PersonID (PK)
FirstName (text)
LastName (text)
Company(text)
Department(text)
Date (date/time)


tblPersonAnswer
PersonAnswerID (PK)
PersonID (text)
QuestionID (number)
AnswerChoiceActual (number)
AnswerChoiceImportance (number)


tblQuestions
QuestionID (PK)
QuestionNumber (text)
QuestionText (text)


I was asked to run a query to get a total sum of the AnswerChoiceActual
and the total sum of AnswerChoiceActual; then multiply those 2 fields
to come up a single answer per record; then add the total of
QuestionID1, QuestionID3 & QuestionID5. I was able to figure out the
following sql to run my first 2 queries:


qry1
SELECT Sum(tblPersonAnswer.AnswerChoiceActual) AS ActualChoice,
Sum(tblPersonAnswer.AnswerChoiceImportance) AS T_ImportanceChoice,
tblPersonAnswer.QuestionID, tblPerson.Department
FROM tblPerson INNER JOIN tblPersonAnswer ON tblPerson.PersonID =
tblPersonAnswer.PersonID
GROUP BY tblPersonAnswer.QuestionID, tblPerson.Department, (QuestionID)
HAVING (((tblPerson.Department)="Exec"));


qry2
SELECT qry1.QuestionID,
[qry1]![ActualChoice]*[qry1]![T_ImportanceChoice] AS TotalScore
FROM qry1;


I've been struggling for a week now on how I can pull only a few
records in a table and get the total sum.


I'm sorry if I gave too much info but I just wanted to be as clear as
possible since I'm also still learning the terminology of this program.
Thank you so much in advance!!!
Nov 1 '06 #1
3 4632
MMcCarthy
14,534 Expert Mod 8TB
Revise your queries as follows:


qry1
SELECT Sum(tblPersonAnswer.AnswerChoiceActual) AS ActualChoice,
Sum(tblPersonAnswer.AnswerChoiceImportance) AS T_ImportanceChoice,
Sum(tblPersonAnswer.AnswerChoiceActual)*Sum(tblPer sonAnswer.AnswerChoiceImportance) As TotalScore,
tblPersonAnswer.QuestionID
FROM (tblPerson INNER JOIN tblPersonAnswer ON tblPerson.PersonID =tblPersonAnswer.PersonID)
WHERE (((tblPerson.Department)="Exec"));
GROUP BY tblPersonAnswer.QuestionID;


qry2
SELECT Sum(IIf(QuestionID=1 Or QuestionID=3 Or QuestionID=5,TotalScore,0)) As SumQ1Q3Q5
FROM qry1;
Nov 1 '06 #2
Thank you so much! Your query is much more simpler than mine.
Nov 2 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Thank you so much! Your query is much more simpler than mine.
You're welcome!

Please repost if you have any further problems.
Nov 7 '06 #4

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

Similar topics

3
by: btopenworld | last post by:
Could someone point me in the right direction for writing, say, three records into three table cells and then starting a new row for the next three records. (I've used While not EOF and MoveNext...
3
by: Oren | last post by:
Hi, I have an Access application with linked tables via ODBC to MSSQL server 2000. Having a weird problem, probably something i've done while not being aware of (kinda newbie). the last 20...
3
by: intl04 | last post by:
I was told by an instructor of Oracle SQL that an MS Access database cannot be used to have several people enter records at about the same time, that the database will "freeze up" as a result -...
8
by: mark | last post by:
Access2000 How do I write a query that combines the CTC field from each record below into one record? I need to concatenate the CTC field with a separator, like below: ...
6
by: Maital | last post by:
Dear experts, I'm a beginner with ms-access. I have data from 3 years of observations on a certain field, divided into North and South sections. The first table has information for about 600...
2
by: zek2005 | last post by:
Hi!!!! I have a list of records as a result of a query. They are displayed with a while sentence... while($row = mysql_fetch_array($res)) at the end of each record, I inserted a checkbox...
9
by: Greg | last post by:
Hi, I have a table with "dates", i'd like to display those dates on a calendar. I've put a calendar in a form, linked to my "date" field, and it works, but only showing one "date" per calendar....
4
by: ske | last post by:
Hi I've inherited an Access database where there is a form setup which prints out a Job Sheet. This works fine with one record. However I need to set it to loop through several records and print...
1
by: bluereign | last post by:
Thank you for your assistance. I am a novice looking to JOIN and append or combine records from 2 current Tables into 2 new Tables named below. I have been able to JOIN Tables with the script...
2
by: farouqdin | last post by:
Hi all i have code which loops through table and deletes the duplicate records. This code does it for one table. How do i change it so it goes through several tables? On Error Resume Next Dim...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
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
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.