S
Sprinks
A while back I asked for help with a query from an Estimates database, where
I wanted to return only the last Estimate record. The very helpful
respondant supplied the following SQL, which works perfectly. Unfortunately,
I did not fully understand how it worked at the time, and I find myself in a
similar situation.
I follow the joins and the selections, but don't understand the
criteria--mostly, why these dummy tables M and T are used. Can anyone teach
me how to fish and explain it?
SELECT M.JobNumber, M.EstimateNumber, tblEstimateTypeList.EstimateType,
M.Amount, M.SForQty, M.Unit, M.Note
FROM tblBids INNER JOIN (tblEstimates AS M INNER JOIN tblEstimateTypeList ON
M.EstimateType=tblEstimateTypeList.EstimateTypeID) ON
tblBids.JobNumber=M.JobNumber
WHERE (((M.EstimateNumber)=(SELECT Max(EstimateNumber) FROM tblEstimates
As T WHERE T.JobNumber = M.JobNumber)) AND ((tblBids.AwardedBid)=True));
Thanks.
Sprinks
I wanted to return only the last Estimate record. The very helpful
respondant supplied the following SQL, which works perfectly. Unfortunately,
I did not fully understand how it worked at the time, and I find myself in a
similar situation.
I follow the joins and the selections, but don't understand the
criteria--mostly, why these dummy tables M and T are used. Can anyone teach
me how to fish and explain it?
SELECT M.JobNumber, M.EstimateNumber, tblEstimateTypeList.EstimateType,
M.Amount, M.SForQty, M.Unit, M.Note
FROM tblBids INNER JOIN (tblEstimates AS M INNER JOIN tblEstimateTypeList ON
M.EstimateType=tblEstimateTypeList.EstimateTypeID) ON
tblBids.JobNumber=M.JobNumber
WHERE (((M.EstimateNumber)=(SELECT Max(EstimateNumber) FROM tblEstimates
As T WHERE T.JobNumber = M.JobNumber)) AND ((tblBids.AwardedBid)=True));
Thanks.
Sprinks