On Thursday, December 29, 2022, Floris Van Nee <
florisvannee@optiver.com> wrote:
Is it expected that Postgres reorders these expressions? I'd think that, even though Postgres decides to inline a query, it should at least evaluate the expressions of the inner-part before the outer part to avoid the division by zero.
Yes, this is working as intended, expression order is not something that is recognized by the system . In this case protect your division with a case expression.
David J.