Last Updated : 11 Jul, 2025
Mathematical functions in MySQL are essential tools for performing a variety of numerical operations directly within SQL queries.
These built-in functions enable users to execute calculations, manipulate numeric data, and perform statistical analysis efficiently. In this article, We will learn about Mathematical functions in MySQL by understanding various methods.
Mathematical functions in MySQLHere’s a tabular representation of commonly used Mathematical functions in MySQL:
Function Description Example ResultABS()
Returns the absolute value of a number. SELECT ABS(-10);
10 CEIL()
or CEILING()
Rounds a number up to the nearest integer. SELECT CEIL(4.3);
5 FLOOR()
Rounds a number down to the nearest integer. SELECT FLOOR(4.7);
4 ROUND()
Rounds a number to a specified number of decimal places. SELECT ROUND(123.456, 2);
123.46 POW()
or POWER()
Returns the result of a number raised to a specified power. SELECT POW(2, 3);
8 SQRT()
Returns the square root of a number. SELECT SQRT(16);
4 EXP()
Returns the value of e raised to the power of a specified number. SELECT EXP(1);
Approximately 2.71828 LOG()
Returns the natural logarithm of a number. SELECT LOG(10);
Approximately 2.30259 RAND()
Returns a random floating-point number between 0 and 1. SELECT RAND();
e.g., 0.123456 SIN()
Returns the sine of an angle in radians. SELECT SIN(PI()/2);
1 COS()
Returns the cosine of an angle in radians. SELECT COS(0);
1 TAN()
Returns the tangent of an angle in radians. SELECT TAN(PI()/4);
1 Advantages of Mathematical Functions in MySQL
Mathematical functions in MySQL provide robust capabilities for manipulating and analyzing numerical data. By using these functions, users can perform complex calculations directly in their SQL queries, facilitating efficient data processing and enhancing reporting capabilities. Whether it's rounding numbers, computing powers, or generating random values, these functions help streamline data transformations and analytical tasks, reducing the need for external processing.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4