DIVIDE()
All functions > MATH > DIVIDE()
Returns the result of dividing the first number by the second as a double.
Signatures
Numeric division
Returns: Result of the division as a double
DIVIDE(dividend: T, divisor: U) → DOUBLE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
dividend | T | Yes | Number to be divided |
divisor | U | Yes | Number to divide by |
With:
T: Any numeric typeU: Any numeric type
Signature notes:
- Both arguments are cast to DOUBLE before division
- Result is always a DOUBLE, even for integer inputs
- Returns NULL if either operand is NULL
- Division by zero raises an error; use TRY_DIVIDE for NULL on divide-by-zero
- For integer division that preserves the dividend type, use DIVIDE_TYPE
Related operators
Examples
DIVIDE(...)
FeatureQL
SELECT
f1 := DIVIDE(10E0, 3E0) -- Function call
;Result
| f1 VARCHAR |
|---|
| 3.3333333333333335 |
.DIVIDE(...) — chained
FeatureQL
SELECT
f1 := (10E0).DIVIDE(3E0), -- Parenthesized DOUBLE base
f2 := 10E0.DIVIDE(3E0) -- DOUBLE literal: chain without extra parentheses
;Result
| f1 VARCHAR | f2 VARCHAR |
|---|---|
| 3.3333333333333335 | 3.3333333333333335 |
Edge cases
FeatureQL
SELECT
f1 := DIVIDE(15E0, 5E0), -- Exact division
f2 := DIVIDE(7E0, 2E0), -- Half result
f3 := DIVIDE(-8E0, 4E0) -- Negative dividend
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 3.0 | 3.5 | -2.0 |