Good morning all, I had a thread going a few days ago on how to get my last record to show in a query which can be found here.
It was sorted by an SQL, I now need to add some extra details to the query from another table and I’m not quite sure what I need to put into the code to do that.
The details that need to come over are FirstName, Surname and Phone and the table name is SupervisiorDetails.
Here is the SQL that was provided to me which was great thanks again.
SELECT
FL.FleetName,
FL.FleetNumber,
FL.[S/N],
FL.NextLiftingTest,
FL.HireStatus,
PL2.Address,
PL2.Area,
PL2.PostCode
FROM
Fleet AS FL
LEFT JOIN
(SELECT
PL.FleetNumber,
PL.Address,
PL.Area,
PL.PostCode
FROM
PlantLocation AS PL
WHERE PL.ID IN
(SELECT First(tP1.ID)
FROM PlantLocation as tP1
GROUP BY
TP1.FleetNumber,
NZ(tP1.OffHireDate, NZ(tP1.OnHireDate, Date()))
HAVING
NZ(tP1.OffHireDate, NZ(tP1.OnHireDate, Date())) =
(SELECT Max(NZ(tP0.OffHireDate, NZ(tP0.OnHireDate, Date())))
FROM PlantLocation AS tP0
Where tP0.FleetNumber = tP1.FleetNumber)
)
) AS PL2
ON FL.FleetNumber = PL2.FleetNumber;