Skip to main content


1. MOD Function

The MOD function in H2 database is used to calculate the remainder when one number is divided by another.

2. Syntax

The syntax for the MOD function in H2 database is as follows:

MOD(dividend, divisor)


  • dividend: The number to be divided. It should be a numeric value.
  • divisor: The number by which the dividend is divided. It should be a non-zero numeric value.


  • The MOD function returns the remainder when the dividend is divided by the divisor.

3. Notes

  • The MOD function in H2 database returns a value with the same sign as the dividend.
  • If either the dividend or the divisor is NULL, the MOD function will return NULL.
  • Be cautious while using the MOD function with floating-point numbers, as it may result in imprecise remainders due to floating-point arithmetic.

4. Examples

Here are a few examples demonstrating the usage of the MOD function in H2 database:

Example 1 - Calculating the remainder of 10 divided by 3:

SELECT MOD(10, 3) AS remainder;



Example 2 - Calculating the remainder when dividing a column by a constant:

CREATE TABLE numbers (
value INT

INSERT INTO numbers VALUES (1, 15), (2, 7), (3, 12);

SELECT id, value, MOD(value, 5) AS remainder
FROM numbers;


id | value | remainder
1 | 15 | 0
2 | 7 | 2
3 | 12 | 2
  • DIV - Integer division
  • round - Round to a specified number of decimal places
  • CEILING - Round up to the nearest integer
  • floor - Round down to the nearest integer