REMAINDER Function in Oracle SQL – PLSQL

The REMAINDER Function in Oracle SQL / PLSQL is used to get the remainder when m is divided by n.

Syntax for the using the REMAINDER Function in Oracle SQL / PLSQL is:

SELECT REMAINDER(m,n)
FROM table_name;

  • The remainder is calculated using the formula:
  • m-(n*A), here A is an integer nearest to m / n.

  • The REMAINDER function in Oracle SQL / PLSQL uses the round function, where as the MOD function in Oracle SQL / PLSQL uses the floor function in it’s calculation.

Examples:

Using REMAINDER Function in Oracle SQL / PLSQL SELECT statement:

SELECT REMAINDER(10,3)
FROM dual;

Will return ‘1’

SELECT REMAINDER(11,3)
FROM dual;

Will return ‘-1’

SELECT REMAINDER(15,6)
FROM dual;

Will return ‘3’

SELECT REMAINDER(15.3,6.5)
FROM dual;

Will return ‘2.3’


Tagged , , , , , , , , , , , . Bookmark the permalink.