PLSQL | MOD Function
The MOD function is an inbuilt function in PLSQL which is used to return the remainder when a is divided by b. Its formula is
.
Syntax:
MOD(a, b)
Parameters Used:
This function accepts two parameters a and b. This function gives remainder as the output when the input number a is divided by b.
Return Value:
This function returns the remainder when a is divided by b.
Supported Versions of Oracle/PLSQL is given below:
- Oracle 12c
- Oracle 11g
- Oracle 10g
- Oracle 9i
- Oracle 8i
Let’s see some examples which illustrate the MOD function:
Example-1:
DECLARE
Test_Number number1 := 15;
Test_Number number2 := 4;
BEGIN
dbms_output.put_line(MOD(Test_Number number1,
Test_Number number2));
END;
Output:
3
In the above example, when the numeric value 15 is divided by 4 then it returns the remainder of 3 as output.
Example-2:
DECLARE
Test_Number number1 := 15;
Test_Number number2 := 0;
BEGIN
dbms_output.put_line(MOD(Test_Number number1,
Test_Number number2));
END;
Output:
15
In the above example, when the numeric value 15 is divided by 0 then it returns the remainder of 15 as output.
Example-3:
DECLARE
Test_Number number1 := 11.6;
Test_Number number2 := 2.1;
BEGIN
dbms_output.put_line(MOD(Test_Number number1,
Test_Number number2));
END;
Output:
1.1
In the above example, when the numeric value 11.6 is divided by 2.1 then it returns the remainder of 1.1 as output.
Advantage:
This function is used to find the remainder when a is divided by b.
Recommended Posts:
- PLSQL | LN Function
- PLSQL | CHR Function
- PLSQL | SIN Function
- PLSQL | COS Function
- PLSQL | LEAST Function
- PLSQL | LOG Function
- PLSQL | ABS Function
- PLSQL | TAN Function
- PLSQL | EXP Function
- PLSQL | LOWER Function
- PLSQL | DBTIMEZONE Function
- PLSQL | EXTRACT Function
- PLSQL | LAST_DAY Function
- PLSQL | ATAN2 Function
- PLSQL | SOUNDEX Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



