Updated on 2026-11-06 GMT+08:00

pmod

The pmod function is used to return the positive modulus of a divided by b.

Syntax

pmod(INT a, INT b)

Parameters

Parameter

Mandatory

Type

Description

a

Yes

DOUBLE, BIGINT, DECIMAL, or STRING

The format of parameter a includes floating-point format, integer format, and string format.

b

Yes

DOUBLE, BIGINT, DECIMAL, or STRING

The format of parameter b includes floating-point format, integer format, and string format.

Return Values

Returns a value of type DECIMAL or INT.

  • If a or b is NULL, NULL is returned.
  • If b is 0, NULL is returned.

Example Code

Returns 2.

select pmod(2,5); 

Returns 1.

select pmod(5,2); 

Returns 0.877.

select pmod(5.123,2.123);