SQLite Forum

Fail to calculate long expression
> Calculating 8 mod 0 is undefined.

That's why SQLite returns a NULL value.

> Shouldn't that be captured when the statement is parsed before it's executed?

How? The operand `0` is an intermediate result while executing resp calculating the long expression. The intermediate result for the right operand of the `%` operator is `-0.0317193865612212`. Since this value is not an integer, it is truncated to `0` by SQLite.

At least the SQL-99 standard does not define the operator `%` - I have not checked newer standard versions. Therefore the implementor decides how the operator works, and SQLite made the decision to cast the operands to integer.