Brug HAVING
HAVING
LatestBookableTimestamp < UNIX_TIMESTAMP()
Som en sidebemærkning bruger du en afhængig underforespørgsel, hvilket er en dårlig idé, når det gælder ydeevne.
Prøv sådan her:
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()