A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

summing a query



 
 
Thread Tools Display Modes
  #1  
Old February 15th, 2007, 10:34 PM posted to microsoft.public.access.queries
Stever
external usenet poster
 
Posts: 31
Default summing a query

Experimenting with summing in a query.

Have a 2 simple tables with part number and qty as fields

ie table 1 part1.....qty1
tablw 2 part 2......qty2

the I set up a make new table query using the two tables with a link between
part1 and part2, and a column that sums the 2 qty together.

Now all is ok as long as I have identical part numbers in both tables, it
returns the values correctly and sums them up. But if I enter a unique part
number in one table and not the other it will not return that part number as
part of the query result.

How can I get the query to return all part numbers even if they only appear
in on table.

I'm using this as a test to then set up a query that will search across a
number of tables and return say all the bolts found even if they do not
appear in all the tables and total up all the same part numbers.

Any help appreciated

SR

  #2  
Old February 15th, 2007, 11:54 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default summing a query

Try an UNION ALL and then sum.

"SteveR" wrote:

Experimenting with summing in a query.

Have a 2 simple tables with part number and qty as fields

ie table 1 part1.....qty1
tablw 2 part 2......qty2

the I set up a make new table query using the two tables with a link between
part1 and part2, and a column that sums the 2 qty together.

Now all is ok as long as I have identical part numbers in both tables, it
returns the values correctly and sums them up. But if I enter a unique part
number in one table and not the other it will not return that part number as
part of the query result.

How can I get the query to return all part numbers even if they only appear
in on table.

I'm using this as a test to then set up a query that will search across a
number of tables and return say all the bolts found even if they do not
appear in all the tables and total up all the same part numbers.

Any help appreciated

SR

  #3  
Old February 16th, 2007, 01:34 PM posted to microsoft.public.access.queries
Stever
external usenet poster
 
Posts: 31
Default summing a query

Karl,

Thanks for that tip.

So I figured out how to set up a UNION query and then run a make table query
on that but I am at a loss as to where to put the SUM expression.

from my example below I created a union query that looks like this;

SELECT [PART NUMBER1], [QTY1]
FROM [TEST1]

UNION ALL SELECT [PART NUMBER2],[QTY2]
FROM [TEST2];

this returns a result listing all part numbers in one column and all qty in
another

So then I create a new table query in which I can add a selection criteria
for user input.

Now the question, how to I add a sum to group all the same part numbers
together and add the qty in a new total column?

Thanks again for any help.




"KARL DEWEY" wrote:

Try an UNION ALL and then sum.

"SteveR" wrote:

Experimenting with summing in a query.

Have a 2 simple tables with part number and qty as fields

ie table 1 part1.....qty1
tablw 2 part 2......qty2

the I set up a make new table query using the two tables with a link between
part1 and part2, and a column that sums the 2 qty together.

Now all is ok as long as I have identical part numbers in both tables, it
returns the values correctly and sums them up. But if I enter a unique part
number in one table and not the other it will not return that part number as
part of the query result.

How can I get the query to return all part numbers even if they only appear
in on table.

I'm using this as a test to then set up a query that will search across a
number of tables and return say all the bolts found even if they do not
appear in all the tables and total up all the same part numbers.

Any help appreciated

SR

  #4  
Old February 16th, 2007, 03:42 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default summing a query

Use the union query as your source in a totals query.

"SteveR" wrote:

Karl,

Thanks for that tip.

So I figured out how to set up a UNION query and then run a make table query
on that but I am at a loss as to where to put the SUM expression.

from my example below I created a union query that looks like this;

SELECT [PART NUMBER1], [QTY1]
FROM [TEST1]

UNION ALL SELECT [PART NUMBER2],[QTY2]
FROM [TEST2];

this returns a result listing all part numbers in one column and all qty in
another

So then I create a new table query in which I can add a selection criteria
for user input.

Now the question, how to I add a sum to group all the same part numbers
together and add the qty in a new total column?

Thanks again for any help.




"KARL DEWEY" wrote:

Try an UNION ALL and then sum.

"SteveR" wrote:

Experimenting with summing in a query.

Have a 2 simple tables with part number and qty as fields

ie table 1 part1.....qty1
tablw 2 part 2......qty2

the I set up a make new table query using the two tables with a link between
part1 and part2, and a column that sums the 2 qty together.

Now all is ok as long as I have identical part numbers in both tables, it
returns the values correctly and sums them up. But if I enter a unique part
number in one table and not the other it will not return that part number as
part of the query result.

How can I get the query to return all part numbers even if they only appear
in on table.

I'm using this as a test to then set up a query that will search across a
number of tables and return say all the bolts found even if they do not
appear in all the tables and total up all the same part numbers.

Any help appreciated

SR

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.