I have two queries is postgresql: As you might have noticed result of the first condition in both queries is true, but result of first query is null and result of the second one is ERROR: division by zero What is happening in here? Is there any optimization in order of evaluation occurring? If yes, is there any why to