Gunakan MEMILIKI
HAVING
LatestBookableTimestamp < UNIX_TIMESTAMP()
Sebagai tambahan, Anda menggunakan subquery dependednt, yang merupakan ide yang buruk dari segi kinerja.
Coba seperti ini:
SELECT
a.ID,
a.DistanceFromUtrecht,
pp.LatestBookableTimestamp
FROM
Accommodation AS a
INNER JOIN (
SELECT
FK_Accommodation,
MAX(DateUntil) - (ReleaseDays * 60 * 60 * 24) AS LatestBookableTimestamp
FROM
PricePeriod
GROUP BY
FK_Accommodation
) AS pp
ON pp.FK_Accommodation = a.ID
WHERE
pp.LatestBookableTimestamp < UNIX_TIMESTAMP()