I've got a table that I want to extract a subset of data from.
It contains three fields of importantance:
leasekey : the foreign key that ties this table to a parent
effectivedate : the data associated with a lease rate
rateSF : the lease rate per square foot.
What I want to do is query the table to get a set of records showing the current rateSF for each leasekey, limiting the data to the MOST recent leaserate in effect by choosing
the Max(tblRateDetails.EffectiveDate) that is <= NOW().
The SQL below works great, returns exactly the records I need, but fails when I try to include the field rateSF, which I need.
Can anyone help me construct this statement so that i get a set of records that show all three fields?
--------------------------------------------------
SELECT Max(tblRateDetails.EffectiveDate) AS MaxOfEffectiveDate, tblRateDetails.LeaseKey
FROM tblRateDetails
WHERE (((tblRateDetails.EffectiveDate)<=Now()))
GROUP BY tblRateDetails.LeaseKey
ORDER BY tblRateDetails.LeaseKey;
--------------------------------------------------
Thanks
Taz
It contains three fields of importantance:
leasekey : the foreign key that ties this table to a parent
effectivedate : the data associated with a lease rate
rateSF : the lease rate per square foot.
What I want to do is query the table to get a set of records showing the current rateSF for each leasekey, limiting the data to the MOST recent leaserate in effect by choosing
the Max(tblRateDetails.EffectiveDate) that is <= NOW().
The SQL below works great, returns exactly the records I need, but fails when I try to include the field rateSF, which I need.
Can anyone help me construct this statement so that i get a set of records that show all three fields?
--------------------------------------------------
SELECT Max(tblRateDetails.EffectiveDate) AS MaxOfEffectiveDate, tblRateDetails.LeaseKey
FROM tblRateDetails
WHERE (((tblRateDetails.EffectiveDate)<=Now()))
GROUP BY tblRateDetails.LeaseKey
ORDER BY tblRateDetails.LeaseKey;
--------------------------------------------------
Thanks
Taz