TRY_DIVIDE

All functions > MATH > TRY_DIVIDE

Returns the result of the division of the first number by the second as a double. Returns NULL if the divisor is zero.

Signatures

Safe numeric division

Returns: Result of the division as a double, or NULL if divisor is zero

TRY_DIVIDE(dividend: T, divisor: T) → DOUBLE
sql
ParameterTypeRequiredDescription
dividendTYesNumber to be divided
divisorTYesNumber to divide by

Notes

  • Both arguments are cast to DOUBLE before division
  • Returns NULL if either operand is NULL
  • Returns NULL if the divisor is zero (instead of raising an error)
  • Result is always a floating-point number, even for integer inputs
  • Safe alternative to DIVIDE when the divisor may be zero

See also

Examples

FeatureQL
SELECT
    f1 := TRY_DIVIDE(10e0, 3e0),  -- Division with remainder
    f2 := TRY_DIVIDE(15e0, 5e0),  -- Exact division
    f3 := TRY_DIVIDE(42e0, 0e0),  -- Division by zero returns NULL
    f4 := TRY_DIVIDE(-8e0, 4e0)  -- Negative division
;
Result
f1 VARCHARf2 VARCHARf3 VARCHARf4 VARCHAR
3.33333333333333353.0NULL-2.0

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19