R
robert d via AccessMonster.com
I'm having trouble constructing a query to retrieve records from a TableA
based on an indicator in TableB and on getting the max date. Here's the data
in TableA and TableB.
TableA
Project Status Date
ProjectA Approved 1/21/2005
ProjectA Awarded 12/21/2005
ProjectB Pending 11/04/2004
ProjectB Study 6/03/2003
ProjectC Approved 1/21/2005
ProjectD Approved 1/21/2005
TableB
Project Status Date SubProjectInd
ProjectA Approved 1/21/2005 Y
ProjectA Awarded 12/21/2005 N
ProjectB Pending 11/04/2004 N
ProjectB Study 6/03/2003
ProjectC Approved 1/21/2005 Y
ProjectD Approved 1/21/2005 N
The three fields shown in TableA make up the primary key. So I want to
select the rows in Table A where the SubProjectInd in TableB is not equal to
"Y" and also I want the Project selected in TableA to be the one with the Max
(Date).
So the results of the query should be Rows 2, 3, and 6 from TableA.
If it makes it easier to make sure that each row in TableB has a SubStatusInd
of either 'Y" or "N" (but with no Nulls or spaces), then this can be arranged.
based on an indicator in TableB and on getting the max date. Here's the data
in TableA and TableB.
TableA
Project Status Date
ProjectA Approved 1/21/2005
ProjectA Awarded 12/21/2005
ProjectB Pending 11/04/2004
ProjectB Study 6/03/2003
ProjectC Approved 1/21/2005
ProjectD Approved 1/21/2005
TableB
Project Status Date SubProjectInd
ProjectA Approved 1/21/2005 Y
ProjectA Awarded 12/21/2005 N
ProjectB Pending 11/04/2004 N
ProjectB Study 6/03/2003
ProjectC Approved 1/21/2005 Y
ProjectD Approved 1/21/2005 N
The three fields shown in TableA make up the primary key. So I want to
select the rows in Table A where the SubProjectInd in TableB is not equal to
"Y" and also I want the Project selected in TableA to be the one with the Max
(Date).
So the results of the query should be Rows 2, 3, and 6 from TableA.
If it makes it easier to make sure that each row in TableB has a SubStatusInd
of either 'Y" or "N" (but with no Nulls or spaces), then this can be arranged.