Dealing with 3 query

A

a

Thank you
query1 (table1)
Id companyname Attemployee
1 Hp 10
2 ms 10
Query2 (table2)
1 hp 8
2 ms 4

the question:
the result for what i want
query 3
the result
1 hp 2
2 ms 6
is possible to subtract 2 query and get result in query 3
thank y ou
 
A

a

Michel Walsh :
Thank you For Your Help and Answer Thank YOU
MR Michel Walsh [MVP]
What Part Of Access Can I learn, to make Query Like This...???
 
A

a

Michel Walsh :
Thank you For Your Help and Answer Thank YOU
MR Michel Walsh [MVP]
What Part Of Access Can I learn, to make Query Like This...???
 
M

Michel Walsh

Hi,


definitively.



oh, you probably also want to know how? :)


SELECT a.id, a.companyName, a.attemployee - b.attemployee
FROM table1 As a INNER JOIN table2 as b
ON a.id=b.id AND a.companyName=b.companyName



Note that if id is a primary key, you can simplify to:

SELECT a.id, a.companyName, a.attemployee - b.attemployee
FROM table1 As a INNER JOIN table2 as b
ON a.id=b.id



That assumes the id is present in both table. If it is present just in
table1:

SELECT a.id, a.companyName, a.attemployee - Nz( b.attemployee, 0)
FROM table1 As a LEFT JOIN table2 as b
ON a.id=b.id

is preferable.... it just subtract 0 when the id is not present in table2,
still showing the original (table1) value, if you prefer.




Hoping it may help,
Vanderghast, Access MVP
 

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