Je kunt een subquery proberen, zoiets als
WHERE
log_timestamp = (
SELECT MAX(log_timestamp)
FROM `bgs`.`faction_log`
WHERE log_timestamp BETWEEN bgs.find_closest_tick_time(date('2017-08-14')) AND bgs.find_closest_tick_time(DATE_ADD(date('2017-08-14'), INTERVAL 1 DAY)) AND associated_system_id = 4
) AND associated_system_id = 4