Query from differnt tables

L

LG

I have tables 5 seperate tables with the same fields in all of them. I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.
 
K

KARL DEWEY

You should have only one. Use a union query to pull them together --
SELECT ID , Batch_ID, Platform, "Tb1" AS [TBL]
FROM Table1
UNION ALL SELECT ID , Batch_ID, Platform, "Tb2" AS [TBL]
FROM Table
UNION ALL SELECT ID , Batch_ID, Platform, "Tb3" AS [TBL]
FROM Table3
UNION ALL SELECT ID , Batch_ID, Platform, "Tb4" AS [TBL]
FROM Table4
UNION ALL SELECT ID , Batch_ID, Platform, "Tb5" AS [TBL]
FROM Table5

The output field [TBL] above is if you really need to know where the data
came from.

Then use a totals query --
SELECT Name, Batch_ID, Count(Batch_ID) AS Batch_Total
FROM Employee LEFT JOIN MyUnionQuery ON Employee.ID = MyUnionQuery
GROUP BY Name, Batch_ID;
 
J

John W. Vinson

I have tables 5 seperate tables with the same fields in all of them.

Then you have a misdesigned database. It would be much better to have ONE
table with an additional field identifying which batch of information this
record belongs to.
I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.

You'll need to create a query with the employee table, and join *all five* of
the other tables to it by ID. Use a "Left Join" - select the join line in the
query window and select option 2 "Show all records in Employees and matching
records in <other table>".
 
L

LG

How do I get it to have date parameters? Where the supervisor or processor
can pull up their completed work by date(s)
KARL DEWEY said:
You should have only one. Use a union query to pull them together --
SELECT ID , Batch_ID, Platform, "Tb1" AS [TBL]
FROM Table1
UNION ALL SELECT ID , Batch_ID, Platform, "Tb2" AS [TBL]
FROM Table
UNION ALL SELECT ID , Batch_ID, Platform, "Tb3" AS [TBL]
FROM Table3
UNION ALL SELECT ID , Batch_ID, Platform, "Tb4" AS [TBL]
FROM Table4
UNION ALL SELECT ID , Batch_ID, Platform, "Tb5" AS [TBL]
FROM Table5

The output field [TBL] above is if you really need to know where the data
came from.

Then use a totals query --
SELECT Name, Batch_ID, Count(Batch_ID) AS Batch_Total
FROM Employee LEFT JOIN MyUnionQuery ON Employee.ID = MyUnionQuery
GROUP BY Name, Batch_ID;

LG said:
I have tables 5 seperate tables with the same fields in all of them. I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.
 
K

KARL DEWEY

Add you date field into the union and totals queries.

LG said:
How do I get it to have date parameters? Where the supervisor or processor
can pull up their completed work by date(s)
KARL DEWEY said:
5 seperate tables with the same fields in all of them.
You should have only one. Use a union query to pull them together --
SELECT ID , Batch_ID, Platform, "Tb1" AS [TBL]
FROM Table1
UNION ALL SELECT ID , Batch_ID, Platform, "Tb2" AS [TBL]
FROM Table
UNION ALL SELECT ID , Batch_ID, Platform, "Tb3" AS [TBL]
FROM Table3
UNION ALL SELECT ID , Batch_ID, Platform, "Tb4" AS [TBL]
FROM Table4
UNION ALL SELECT ID , Batch_ID, Platform, "Tb5" AS [TBL]
FROM Table5

The output field [TBL] above is if you really need to know where the data
came from.

Then use a totals query --
SELECT Name, Batch_ID, Count(Batch_ID) AS Batch_Total
FROM Employee LEFT JOIN MyUnionQuery ON Employee.ID = MyUnionQuery
GROUP BY Name, Batch_ID;

LG said:
I have tables 5 seperate tables with the same fields in all of them. I have
a seperate table with employees id and their name.
I need to set up a query for a report that will have the information to pull
into 1.
Ex. The report needs to show how many batch_id in each platform with their
name showing instead of their ID.
Fields : ID , Batch_ID, Platform
The employee table has ID and name.
Outcome would be ex: Smith 62 commerical, Smith 62 Medical than a total.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

query 5
Combining Queries to get 1 Report 1
query assistance 3
Payroll Database - Need Help!! 1
Query-Report 1
Sum 1
Linked tables 2
Querying 2 Tables 4

Top