Hi, I would like to create a query in which I recall data from 2 tables in completely separate databases. Firstly, we have my database that manages the 'test status' of various units in manufacturing, all of which have unique serial numbers that go through different test stages. Every time the unit go through a test stage a new record is created to maintain history.
Then we have another database, run by a different dept, that tracks all the units and keeps a history of their 'location'. The location of the units could be Scotland, Harlow, or the US.
What I'm trying to create is a query that will output the latest 'test status' for units that are currently in Harlow.
My problem, I have tables that look like this in an extremely simplified form:
Test Status Table
Unit SerialNo TestStatus Date
A 001 1st test 11-09-08
A 001 repair 13-09-08
B 001 1st test 15-09-08
C 005 2nd test 03-09-08
Location Table
Unit SerialNo Location Date
A 001 US 01-09-08
A 001 Harlow 02-09-08
B 001 Harlow 14-09-08
B 001 US 17-09-08
C 005 Harlow 01-09-08
The query I would like to create should look like this:
Unit SerialNo TestStatus Date Location
A 001 repair 13-09-08 Harlow
C 005 2nd test 03-09-08 Harlow
Unit B is not reported by the query because it is no longer in Harlow, it was shipped to the US to the 17-09-08.
Where I'm stuck:
1) Where I'm stuck is that I don't know a method of recalling the latest record (by date), for each unit (by serial number) that are currently in Harlow. I can't simply filter on "Harlow" as this will bring up units that were previously in Harlow and have subsequently been shipped.
2) The same problem I have applies to the Test Status, I don't know how to recall the latest record only.
Any help is very much appreciated as usual
Then we have another database, run by a different dept, that tracks all the units and keeps a history of their 'location'. The location of the units could be Scotland, Harlow, or the US.
What I'm trying to create is a query that will output the latest 'test status' for units that are currently in Harlow.
My problem, I have tables that look like this in an extremely simplified form:
Test Status Table
Unit SerialNo TestStatus Date
A 001 1st test 11-09-08
A 001 repair 13-09-08
B 001 1st test 15-09-08
C 005 2nd test 03-09-08
Location Table
Unit SerialNo Location Date
A 001 US 01-09-08
A 001 Harlow 02-09-08
B 001 Harlow 14-09-08
B 001 US 17-09-08
C 005 Harlow 01-09-08
The query I would like to create should look like this:
Unit SerialNo TestStatus Date Location
A 001 repair 13-09-08 Harlow
C 005 2nd test 03-09-08 Harlow
Unit B is not reported by the query because it is no longer in Harlow, it was shipped to the US to the 17-09-08.
Where I'm stuck:
1) Where I'm stuck is that I don't know a method of recalling the latest record (by date), for each unit (by serial number) that are currently in Harlow. I can't simply filter on "Harlow" as this will bring up units that were previously in Harlow and have subsequently been shipped.
2) The same problem I have applies to the Test Status, I don't know how to recall the latest record only.
Any help is very much appreciated as usual
