Currently, the query SELECT MAX(height) FROM %s WHERE ? >= time AND EXISTS (SELECT * FROM %s WHERE ? <= time) will return one row with value NULL if no such rows match the predicates. And NULL is taken as 0, which confuse the consumer of the this api