R
Robert
Hi,
There is a database that forms a 1:M relationship for Premises and Lease
Details. In the Lease entity, it keeps the history of the lessee and expiry
date.
I have created an aggregate function to select the Premises Details with
the latest Lease Date (By using MAX function).
However, I link the Equipment and Lease tables to the Access Front End and
add the aforementioned query as well. I find that the query result
is not editable AS it is an aggregate function. In this way, I have
changed to using subquery.
To my disappointment, the query only returns only 1 row - Premises
with Lease information with the largest "Lease Expiry" date.
The SQL is as follow:
SELECT tblPremises.[Record ID], tblPremises.[Expenditure Allocation Code],
, tblPremises.[Premises Address], tblLeases.[Sub-Number],
tblLeases.[Lessee Details], tblLeases.[Phone Number 1], tblLeases.[Phone
Contact Person 1],
tblLeases.[Account Number], tblLeases.[Gross Rent Per Annum],
tblLeases.[Lease Expiry], tblLeases.Insurance, tblLeases.Comments
FROM tblPremises INNER JOIN tblLeases ON tblPremises.[Record ID] =
tblLeases.PremisesID
WHERE tblLeases.[Lease Expiry] = (SELECT (MAX([Lease Expiry])) from
tblLeases)
Is there anything wrong ?
There is a database that forms a 1:M relationship for Premises and Lease
Details. In the Lease entity, it keeps the history of the lessee and expiry
date.
I have created an aggregate function to select the Premises Details with
the latest Lease Date (By using MAX function).
However, I link the Equipment and Lease tables to the Access Front End and
add the aforementioned query as well. I find that the query result
is not editable AS it is an aggregate function. In this way, I have
changed to using subquery.
To my disappointment, the query only returns only 1 row - Premises
with Lease information with the largest "Lease Expiry" date.
The SQL is as follow:
SELECT tblPremises.[Record ID], tblPremises.[Expenditure Allocation Code],
, tblPremises.[Premises Address], tblLeases.[Sub-Number],
tblLeases.[Lessee Details], tblLeases.[Phone Number 1], tblLeases.[Phone
Contact Person 1],
tblLeases.[Account Number], tblLeases.[Gross Rent Per Annum],
tblLeases.[Lease Expiry], tblLeases.Insurance, tblLeases.Comments
FROM tblPremises INNER JOIN tblLeases ON tblPremises.[Record ID] =
tblLeases.PremisesID
WHERE tblLeases.[Lease Expiry] = (SELECT (MAX([Lease Expiry])) from
tblLeases)
Is there anything wrong ?