DIV
Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Returns the integer quotient of two numbers.
Syntax
Arguments
Required
<y>: The dividend.
<x>: The divisor.
Returns
Returns the integer quotient of y/x by using the same data type as the input. Returns bigint for numeric input.
Considerations
- The quotient is truncated toward zero.
- A divisor (
x) of zero returns an error.
Examples
Get an Integer Quotient
Divide two integers and discard the remainder.
1SELECT div(9, 4) AS result;
Returns 2.
Ignore Division-by-Zero Errors
Normally, division by zero results in a query error. To return NULL instead, use NULLIF.
1SELECT a / NULLIF(b, 0) AS result;
Returns NULL when b is zero.
Related Documentation