SQL Mathematical Functions | POWER(), ROUND(), MOD() | Complete Notes | CBSE Class 12 Informatics Practices (2026–27)
Class 12 · Informatics Practices
SQL Mathematical Functions
Mathematical functions in SQL perform calculations on numeric values and return the result. These functions are commonly used while retrieving data from a database and help simplify complex calculations without modifying the stored data.
According to the CBSE Class 12 Informatics Practices syllabus, the following mathematical functions are included:
- POWER()
- ROUND()
- MOD()
Why Use Mathematical Functions?
- Perform calculations directly in SQL queries.
- Reduce manual computation.
- Generate accurate reports.
- Improve query efficiency.
- Useful in business, banking, education, and analytics.
1. POWER() Function
The POWER() function returns the value of a number raised to the specified power.
Syntax
POWER(number, exponent)
Example 1
SELECT POWER(2,3);Output
8
Because: 2 × 2 × 2 = 8
Example 2
SELECT Name,
POWER(Marks,2)
FROM Student;
Displays the square of the marks of each student.
2. ROUND() Function
The ROUND() function rounds a number to the specified number of decimal places.
Syntax
ROUND(number, decimal_places)
Example 1
SELECT ROUND(45.6789,2);Output
45.68
Example 2
SELECT ROUND(45.6789,0);Output
46
Example 3
SELECT Name,
ROUND(Percentage,1)
FROM Student;
Displays the percentage rounded to one decimal place.
3. MOD() Function
The MOD() function returns the remainder after dividing one number by another.
Syntax
MOD(dividend, divisor)
Example 1
SELECT MOD(17,5);Output
2
Because: 17 ÷ 5 = 3 remainder 2
Example 2
SELECT MOD(24,6);Output
0
The remainder is zero because 24 is completely divisible by 6.
Using Mathematical Functions with a Table
Consider the following table:
| RollNo | Name | Marks | Percentage |
|---|---|---|---|
| 101 | Amit | 85 | 84.67 |
| 102 | Neha | 92 | 91.82 |
| 103 | Rohan | 78 | 77.45 |
Example Queries
Square of Marks
SELECT Name,
POWER(Marks,2)
FROM Student;
Rounded Percentage
SELECT Name,
ROUND(Percentage,1)
FROM Student;
Find Odd or Even Roll Numbers
SELECT RollNo,
MOD(RollNo,2)
FROM Student;
If the result is:
- 0 → Even Number
- 1 → Odd Number
Comparison of Mathematical Functions
| Function | Purpose | Example |
|---|---|---|
| POWER() | Raises a number to a power | POWER(2,3) |
| ROUND() | Rounds a number | ROUND(45.67,1) |
| MOD() | Returns remainder | MOD(17,5) |
Real-Life Applications
| Function | Application |
|---|---|
| POWER() | Scientific calculations, compound interest |
| ROUND() | Salary, marks, GST calculations |
| MOD() | Checking odd/even numbers, cyclic operations |
Common Errors
| Error | Reason |
|---|---|
| Syntax Error | Incorrect function syntax. |
| Unknown Column | Incorrect column name. |
| Incorrect Number of Arguments | Missing one or more function parameters. |
Quick Revision
| Function | Purpose | Syntax |
|---|---|---|
| POWER() | Raise to a power | POWER(a,b) |
| ROUND() | Round a value | ROUND(a,n) |
| MOD() | Find remainder | MOD(a,b) |
CBSE Exam Tips
- Remember that
POWER(number, exponent)calculates powers. - Use
ROUND(number, decimal_places)for rounding decimal values. MOD()is frequently used to check whether a number is odd or even.- Practice writing SQL queries using these functions with table data.
- Understand the output of function-based SQL queries.
Summary
SQL Mathematical Functions simplify numeric calculations while retrieving data from a database. The POWER() function raises a number to a given power, ROUND() rounds decimal values to the required precision, and MOD() returns the remainder after division. These functions are widely used in SQL queries for reporting, analysis, and real-world database applications.