Dealing with 3 query

  • Thread starter Thread starter a
  • Start date Start date
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
 
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...???
 
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...???
 
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
 
Back
Top