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
-- Function call
f1 := DIVIDE(10e0, 3e0)
;Result
| f1 VARCHAR |
|---|
| 3.3333333333333335 |
.DIVIDE(...) — chained
FeatureQL
SELECT
-- Parenthesized DOUBLE base
f1 := (10e0).DIVIDE(3e0),
-- DOUBLE literal: chain without extra parentheses
f2 := 10e0.DIVIDE(3e0)
;Result
| f1 VARCHAR | f2 VARCHAR |
|---|---|
| 3.3333333333333335 | 3.3333333333333335 |
Edge cases
FeatureQL
SELECT
-- Exact division
f1 := DIVIDE(15e0, 5e0),
-- Half result
f2 := DIVIDE(7e0, 2e0),
-- Negative dividend
f3 := DIVIDE(-8e0, 4e0)
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 3.0 | 3.5 | -2.0 |