• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql

syntax and example of mod function in oracle sql

MOD Function in Oracle SQL – PLSQL

November 5, 2012 by techhoneyadmin

The MOD function in Oracle SQL / PLSQL is used to get the remainder of ‘n’ divided by ‘m’.

Syntax for the MOD function in Oracle SQL / PLSQL is:

SELECT MOD(n,m)
FROM table_name;

  • MOD is calculated as n – m * floor(n/m)
  • MOD function uses floor in the calculation whereas remainder function uses round function in its calculation.
  • MOD function will return ‘n’ if ‘m’ is ‘0’.

Example 1:

view source
print?
1SELECT MOD(5,2)
2FROM DUAL;

Will return “1” because 1 will be remainder if 5 is divided by 2


Example 2:

view source
print?
1SELECT MOD(6,2)
2FROM DUAL;

Will return “0” because there is no remainder if 6 is divided by 2


Example 3:

view source
print?
1SELECT MOD(-5,2)
2FROM DUAL;

Will return “-1” because -1 will be remainder if -5 is divided by 2


Example 4:

view source
print?
1SELECT MOD(5,0)
2FROM DUAL;

Will return “5”


Example 5:

view source
print?
1SELECT MOD(5.5,2)
2FROM DUAL;

Will return “1.5” because 1.5 will be remainder if 5.5 is divided by 2


Filed Under: function Tagged With: how to use mod function in oracle database query, how to use mod function in oracle plsql, how to use mod function in oracle sql, mod function in oracle plsql, mod function in oracle sql, MODPLSQL, syntax and example of mod function in oracle database query, syntax and example of mod function in oracle plsql, syntax and example of mod function in oracle sql, using mod function in oracle database query, using mod function in oracle plsql, using mod function in oracle sql

Copyright © 2025 · Parallax Pro on Genesis Framework · WordPress · Log in