Query from 2 queries.

  • Thread starter Thread starter Roger Martens
  • Start date Start date
R

Roger Martens

In have 2 queries A and B. A with following fields: Year, Period,Machine,
Production and B with Year, Period, Machine, Hours. I should like to make a
report with this records and calculate the production per hour for each.
machine. I make one query with A and B as a source for this report. But it
does'nt work. Why
Erato.
 
Try this:

-Create a new query
-Change to SQL view
-Paste this SQL statement

SELECT A.Year, A.Period, A.Machine, Sum(A.Production) AS Total_Production,
Sum(B.Hours) AS Total_Hours, [Total_Production]/[Total_Hours] AS
Production_Per_Hour
FROM A INNER JOIN B ON (A.Machine = B.Machine) AND (A.Period = B.Period) AND
(A.Year = B.Year)
GROUP BY A.Year, A.Period, A.Machine;

-Replace your table names A and B with your actual table names
-Run the query, this query assumes that your fields Yer,Period,Machine are
of the same type in both tables and that Production and Hours are numbers
 
It doesnt work and itgives an error message or it just doesnt return records.
I would say start by checking the fields in your table to see that they have
the same properties
e.g year in both tables is number long or else, but the same.
 

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

Back
Top