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

Query to show totals from multiple tables

14
Hello again,
I have come across a brick wall in my database. I am looking for a Query to show me the combined information from multiple tables on one report. Each table has its own Query showing me the info I need but now I need to see all 14 of then combined. Such as Sum of totals and the company names from each table. These tables are not joined to each other, not sure if this helps.

Any suggestion would be appreciated.
Jan 30 '08 #1
4 8858
jaxjagfan
254 Expert 100+
Hello again,
I have come across a brick wall in my database. I am looking for a Query to show me the combined information from multiple tables on one report. Each table has its own Query showing me the info I need but now I need to see all 14 of then combined. Such as Sum of totals and the company names from each table. These tables are not joined to each other, not sure if this helps.

Any suggestion would be appreciated.
Make a Union query to pull all 14 totals together. You will have to switch the QBE to SQL view to build a Union query.

Select Sum(Query1.YourValue) as Total From Query1;
UNION
Select Sum(Query2.YourValue) as Total From Query2;
UNION
Select Sum(Query3.YourValue) as Total From Query3;
...

Then:

Select Sum(MyUnionQry.Total) From MyUnionQry;

You could also do this with 14 DSum's:

=DSum("[YourValue]","Query1")+DSum("[YourValue]","Query2") + ...
Jan 30 '08 #2
dponce
14
Thx for you help jaxjagfan,
I am not familiar with SQL but willing to try it out seeing that you generously provided the code for me.

I have entered the following to test it and even renamed my original Query’s to “Query1”, etc… and when I try to run it I get the following error message: Characters found after end of SQL statement.

Select Sum(Query1.Produced) as Total From Query1;
UNION
Select Sum(Query2.Produced) as Total From Query2;
UNION
Select Sum(Query3.Produced) as Total From Query3;
Then
Select Sum(MyUnionQry.Total) From MyUnionQry;
Jan 30 '08 #3
dponce
14
Thx jaxjagfan,
I just wanted to let you know that I was able to collect the information using your second method with the DSum. Works great, I really appreciated it. I would have still loved to learn how to make it work using the SQL format. Nothing big, if you get the chance or anyone else if you could educate me a little more on how to get this to work using the SQL UNION Query format. This is just incase I come across another one of these obstacles.
Jan 30 '08 #4
jaxjagfan
254 Expert 100+
You would need to do the all of the Selects/Unions and save that as a query (I.E. qryMyUnion). That would gather all of the values together in one point to reference. You can make a query in the query designer and select qryMyUnion as the source - you don't have to use SQL statements.

I'm a SQL Server DBA - Don't work in Access a lot here but still like to help. I answer posts while running my daily DTS jobs. We post the SQL here as examples or solutions as to what the SQL would look like but a lot of what we post can be done in the query designer. No one wants to type step by step on what to do there.

HTH
Jan 30 '08 #5

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

Similar topics

5
by: Sami | last post by:
I can create queries and reports based on info from one table. How do I create one using information from multiple tables. What do I need to make sure the information from one table will be...
1
by: Raj | last post by:
Hi I am trying to populate datagrid with a query which has multiple tables on it. It loads data fine but when I try to apply tablestylegrid and columnstyles its not taking it. Can anybody...
8
by: Jason L James | last post by:
Hi all, does anyone know if I can create a dataview from multiple datatables. My dataset is constructed from four separate tables and then the relationships are added that link the tables...
5
by: mimo | last post by:
Hello, I have seen samples on how to pull data from one table and save back to it using the Form View control. How do I pull from multiple tables and save back to multiple tables on one...
8
by: beretta819 | last post by:
Ok, so I apologize in advance for the wordiness of what follows... (I am not looking for someone to make this for me, but to point me in the right direction for the steps I need to take.) I was...
10
by: VirtualLilac | last post by:
Hi, Am trying to build a database for non-profit organisation, its a volunteer job and nobody around to guide me. From my learning I could able to build few reports and forms but am feeling stuck...
4
by: dreaken667 | last post by:
I have a MySQL database containing 16 tables of data. Each table has a different number of columns and there are few common field names accross tables. I do have one master table with which I connect...
0
by: SamKhazary | last post by:
I have created a database that has a main table with a description of different products. I have 5 other data bases that are linked sheets that have returns for the 5 different prduct groups. I'd...
8
by: obtrs | last post by:
show data of multiple tables? i have 3 tables i want to show the data from them to a page. table1 "trip" table2 "seat" table3 "user_information" show all the data of table one which is...
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: 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
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...

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.