---
title: div operator
description: Learn the syntax of the div operator of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/div
---

# `div` operator

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns the integral part of the division of `dividend` by `divisor`.

## Syntax

```
dividend div divisor
```

## Arguments

* `dividend`: An expression that evaluates to a numeric or interval.
* `divisor`: A matching interval type if `dividend` is an interval, a numeric otherwise.

Interval is supported **since**: Databricks Runtime 10.1

## Returns

A `BIGINT`, except for DECFLOAT inputs.

For DECFLOAT inputs, the result is `DECFLOAT(16)` when both operands are `DECFLOAT(16)`, and `DECFLOAT(34)` otherwise. Division by zero produces infinity or NaN, regardless of ANSI mode. `DIV` removes the fractional part of the result, regardless of `DECFLOAT_ROUNDING_MODE`. See [`DECFLOAT` type](https://docs.databricks.com/aws/en/sql/language-manual/data-types/decfloat-type.md).

For other input types, the following error behavior applies:

If `divisor` is `0`, `INTERVAL '0' SECOND` or `INTERVAL '0' MONTH` the operator raises a [DIVIDE\_BY\_ZERO](https://docs.databricks.com/aws/en/error-messages/divide-by-zero-error-class.md) error.

If the division overflows the result type, Databricks raises an [ARITHMETIC\_OVERFLOW](https://docs.databricks.com/aws/en/error-messages/arithmetic-overflow-error-class.md) error.

> [!NOTE]
>
> For inputs other than DECFLOAT, in Databricks Runtime, if [spark.sql.ansi.enabled](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-ansi-compliance.md) is `false`, the function returns `NULL` instead of a [DIVIDE\_BY\_ZERO](https://docs.databricks.com/aws/en/error-messages/divide-by-zero-error-class.md) error.

## Common error conditions

* [ARITHMETIC\_OVERFLOW](https://docs.databricks.com/aws/en/error-messages/arithmetic-overflow-error-class.md)
* [DIVIDE\_BY\_ZERO](https://docs.databricks.com/aws/en/error-messages/divide-by-zero-error-class.md)

## Examples

```sql
> SELECT 3 div 2;
 1
> SELECT -5.9 div 1;
 -5

> SELECT -5.9 div 0;
 Error: DIVIDE_BY_ZERO

> SELECT INTERVAL '100' HOUR div INTERVAL '1' DAY;
 4
```

## Related functions

* [`/` (slash sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/slashsign.md)
* [`*` (asterisk sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/asterisksign.md)
* [`+` (plus sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/plussign.md)
* [`-` (minus sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/minussign.md)
