DIV

DIV is an arithmetic operator in SQL, used to perform division operation on numeric data types. The syntax includes two operands separated by the DIV keyword, where the first operand is divided by the second one. The result is always an integer.

Example

SELECT 10 DIV 3;

Output

3

Explanation

The DIV operator in MySQL performs integer division. The above SELECT statement returns the quotient of 10 divided by 3, which is 3 as it gives the result as integer.

Example

SELECT 15 DIV 2;

Output

7

Explanation

The “DIV” operator in SQL performs an integer division, i.e., it will return only the integer part of the division. For instance, in the above code “15 DIV 2” gives an output “7” discarding the decimal part.

Example

SELECT 10 DIV 3 FROM dual;

Output

3

Explanation

The DIV operation in Oracle performs integer division, where the output is the largest integer value that is less than or equal to the exact quotient. In this case, 10 divided by 3 equals to 3.33. The largest integer value less than or equal to 3.33 is 3, therefore the output of the DIV operation is 3.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.