Bruce, I think you may be on to something here. But I don't have two
different tables. I have tblCorrespondence only. You have named two:
Correspondence and PreviousCorrespondence. Perhaps there is a meaning
to your example that I can interpret and use, but I am having some
trouble doing so. I appreciate you taking a stab at it.
Simply stated, what is expected out of the final query is this: It is
to list certain records from tblCorrespondence meeting specified
criteria in the [OutDate] and [OutType] fields ==but only those
records for which earlier records of the same [VehicleJobID] field
value with [OutDate] and [OutType] fields of specified criteria exist
in the SAME table. Well, maybe not simply stated, but accurately
stated.
Forgive me if I have completely misinterpreted the meaning you were
trying to convey with the example.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxx
On 20 Dec 2006 11:50:47 -0800,
deluxeinformation@gmail.com wrote:
Quote:
>What I'm guessing you want to do is list all correspondence records
>with a Null OutDate and the OutDate of a previous correspondence record
>with the same vehiclejobID and latest OutDate. If so, perhaps this
>will work:
>
>SELECT Correspondence.ID, Correspondence.VehicleJobID,
>Correspondence.OutDate, Correspondence.OutType,
>PreviousCorrespondence.OutDate14
>FROM Correspondence INNER JOIN [SELECT Correspondence.VehicleJobID,
>Max(Correspondence.OutDate) AS OutDate14
>FROM Correspondence
>WHERE Correspondence.OutType=14
>GROUP BY Correspondence.VehicleJobID]. AS PreviousCorrespondence ON
>Correspondence.VehicleJobID = PreviousCorrespondence.VehicleJobID
>WHERE Correspondence.OutDate Is Null;
>
>Bruce