Hi,
I have two tables (MatMast and ChangeLog) in an Access Database, where the common key is MatCode. The tables look like this:
MatMast
MatCode (PK), CurrentStatus
10001, ACTIVE
10002, INACTIVE
10003, ACTIVE
ChangeLog
ChangeInstance (PK), MatCode, Status, TimeStamp
25452, 10001, ACTIVE, 19-Dec-2012 11:21 AM
25678, 10001, INACTIVE, 20-Dec-2012 06:45 PM
20296, 10002, ACTIVE, 20-Dec-2012 03:52 PM
My job now is to write an SQL Query in Access (not allowed to use VBA :shocked: for this) to update the MatMast table into this:
MatMast (After proposed update query)
MatCode (PK), CurrentStatus
10001, INACTIVE <== Picking up ChangeInstance 25678, which is the latest for 10001
10002, ACTIVE <== Picking up ChangeInstance 20296, which is the ONLY rec for 10002
10003, ACTIVE <== Unchanged, as there are no records for this in ChangeLog
Tried various approaches. But, I am not able to write an update query to do this. Please, Please help!
Regds,
SKB
I have two tables (MatMast and ChangeLog) in an Access Database, where the common key is MatCode. The tables look like this:
MatMast
MatCode (PK), CurrentStatus
10001, ACTIVE
10002, INACTIVE
10003, ACTIVE
ChangeLog
ChangeInstance (PK), MatCode, Status, TimeStamp
25452, 10001, ACTIVE, 19-Dec-2012 11:21 AM
25678, 10001, INACTIVE, 20-Dec-2012 06:45 PM
20296, 10002, ACTIVE, 20-Dec-2012 03:52 PM
My job now is to write an SQL Query in Access (not allowed to use VBA :shocked: for this) to update the MatMast table into this:
MatMast (After proposed update query)
MatCode (PK), CurrentStatus
10001, INACTIVE <== Picking up ChangeInstance 25678, which is the latest for 10001
10002, ACTIVE <== Picking up ChangeInstance 20296, which is the ONLY rec for 10002
10003, ACTIVE <== Unchanged, as there are no records for this in ChangeLog
Tried various approaches. But, I am not able to write an update query to do this. Please, Please help!
Regds,
SKB