DIVIDE
All functions > MATH > DIVIDE
Returns the result of the division of the first number by the second as a double.
Signatures
Numeric division
Returns: Result of the division as a double
DIVIDE(dividend: T, divisor: T) → DOUBLE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
dividend | T | Yes | Number to be divided |
divisor | T | Yes | Number to divide by |
Notes
- Both arguments are cast to DOUBLE before division
- Returns NULL if either operand is NULL
- Division by zero raises an error on all backends
- For integer division that preserves type, use DIVIDE_TYPE
- For safe division that returns NULL on divide-by-zero, use TRY_DIVIDE
- Operator form:
dividend / divisor - Result is always a floating-point number, even for integer inputs
See also
Examples
FeatureQL
SELECT
f1 := DIVIDE(10e0, 3e0), -- Division with remainder
f2 := DIVIDE(15e0, 5e0), -- Exact division
f3 := DIVIDE(7e0, 2e0), -- Half result
f4 := DIVIDE(-8e0, 4e0), -- Negative division
f5 := DIVIDE(22e0, 7e0) -- Pi approximation
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR | f5 VARCHAR |
|---|---|---|---|---|
| 3.3333333333333335 | 3.0 | 3.5 | -2.0 | 3.142857142857143 |
On this page