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

calculating a total

heres the deal,
access 97
i have 2 tables,

tblmain and tblpend

tblmain has a "tracking number" which is a primary key and has a 1 to many with tblpend.
tbl pend has a field "days".

for 1 "tracking number" from tblmain, there can be several records with "days" in tblpend

how would i have a query tally up the number of days for the 1 tracking number?
Feb 11 '09 #1
2 1502
DonRayner
489 Expert 256MB
Here is the SQL to achieve what you want.
Expand|Select|Wrap|Line Numbers
  1. SELECT tblMain.[Tracking Number], Sum(tblPend.Days) AS SumOfDays
  2. FROM tblPend INNER JOIN tblMain ON tblPend.[Tracking Number] = tblMain.[Tracking Number]
  3. GROUP BY tblMain.[Tracking Number];
Feb 11 '09 #2
NeoPa
32,556 Expert Mod 16PB
To get this in the Query design window :
  1. Add both tables.
  2. Join them by dragging the [Tracking Number] from one table over that of the other.
  3. Click on the Totals button (The sigma in the Query Design toolbar).
  4. Add both fields ([Tracking Number] from tblMain & Days from tblPend)
  5. Leave [Tracking Number] as "Group By".
  6. Change "Days" to "SumofDays: Days".
  7. Change "Group By" to "Sum".
This will produce the same SQL in the query as that shown by Don.
You can always access (See; update; copy; paste) the SQL for a QueryDef (Access stored query) by selecting SQL from the View menu while the QueryDef is open. You can easily create the query that Don posted by creating a new QueryDef and simply pasting the SQL in to that window from here. If you switch back to "Design" view you will see the same thing displayed in the usual way.
Feb 13 '09 #3

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

Similar topics

4
by: John | last post by:
hey all..... alright, I am frusterated to the point of throwing my machine out the window (this board went down, trying to find stuff on google, this has been a nightmare) so I hope you guys can...
0
by: hlam | last post by:
Help - Calculating the total of a column in a data grid -- when data grid is part of Master-Detail set-up I have setup a Master-Detail form using Visual Studio.Net. A ListBox is the (Master)...
5
by: steve | last post by:
Hi All Not sure if this is the right forum, but I need the formula for calculating the amount of Sales tax (GST) from the tax included price In Australia GST is 10% and the standard formula is...
10
by: Lisa | last post by:
In translating the formula for calculating lottery odds for various conditions into a Visual Basic Program, I have apparently missed something in that I get errors in the part of the calculation...
9
by: mankolele | last post by:
Hi all I need an idea on where to start when calculating a total amount betwee n two dates from a database like I want amount of money paid out from 30/03/2004 and 30/07/2004 ,but in the database...
6
by: richbneal | last post by:
I really like the site so far and this is my first post. I have looked through some of the archives with no luck. I have also read the posting guidelines and will do my best to be clear and accurate...
3
rcollins
by: rcollins | last post by:
I ahve a database that I put together to keep track of the office supplies. We input what has been purchased and what goes out. When I run a report, usually it is just for a month, but I have a...
4
lee123
by: lee123 | last post by:
hello it's me again; i am having a problem with calculating some totals in my project. I have fields on my form that need to be calculated to get a percentage in the end I wish i could show you...
11
by: charmeda103 | last post by:
i have to calculate a total amount of pounds for my program. i am getting each pound calculated but i have to add up all those pounds into one total. the problem is one of the total pounds is not...
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.