combining 2 query/tables

P

Paphiat

I have 2 tables/query that i would like to combine to make a simple
form/report for. The data was downloaded from the system and I am not
able to change the format. What i need to do is make a simple report
that compare the 2 queries result that show that there is no
variance. Thank you.

Query 1 sample
model Type Amount
1 freight cost 100
1 processing cost 200
2 freight cost 150
2 processing cost 175
3 freight cost 210
3 processing cost 234

Query 2 sample
model freight processing cost
1 100 200
2 150 175
3 210 234
 
J

John Spencer

Use a union query to normalize the data in query two

SELECT Model, "Freight Cost" as [Type], Freight as Amount
FROM Query2
UNION ALL
SELECT Model, "ProcessingCost" as [Type], [Processing Cost] as Amount
FROM Query2

Then you can join the union query to query one

SELECT QueryOne.Model
, QueryOne.Type
, QueryOne.Amount
, QueryTwo.Amount
FROM QueryOne LEFT JOIN queryUnion
ON QueryOne.Model = QueryUnion.Model
AND QueryOne.Type = QueryUnion.Type
WHERE QueryOne.Amount <> QueryUnion.Amount
OR QueryUnion.Amount is Null
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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

Top