[Solved] Generalized way to remove empty row given by aggregate functions in SQLite

You are overcomplicating things with the use of the aggregate function MAX(). This part of your code: EXISTS ( SELECT 1 FROM ( SELECT MAX(TourCompletionDateTime) AS TourCompletionDateTime FROM Details WHERE TourCompletionDateTime < ‘2022-07-26T09:36:00.730589Z’ ) WHERE TourCompletionDateTime IS NOT NULL ) is equivalent to just: EXISTS ( SELECT 1 FROM Details WHERE TourCompletionDateTime < ‘2022-07-26T09:36:00.730589Z’ ) … Read more