ROUND():
ROUND() is used to round a numeric value to a specified number of decimal places.Example:
sqlCopy code
SELECT ROUND(3.14159265, 2) AS rounded_value;
Output: 3.14
CEIL() and FLOOR():
CEIL() (or CEILING()) rounds a number up to the nearest integer, while FLOOR() rounds it down to the nearest integer.Example:
sqlCopy code
SELECT CEIL(4.3) AS ceiling_value, FLOOR(4.9) AS floor_value;
Output: 5, 4
ABS():
ABS() returns the absolute value of a number.Example:
sqlCopy code
SELECT ABS(-10) AS absolute_value;
Output: 10
SQRT():
SQRT() calculates the square root of a number.Example:
sqlCopy code
SELECT SQRT(25) AS square_root;
Output: 5
POWER():
POWER() raises a number to a specified power.Example:
sqlCopy code
SELECT POWER(2, 3) AS result;
Output: 8
RAND():
RAND() generates a random floating-point number between 0 and 1.Example:
sqlCopy code
SELECT RAND() AS random_number;
Output: A random number between 0 and 1.
MOD():
MOD() returns the remainder of a division operation.Example:
sqlCopy code
SELECT MOD(10, 3) AS remainder;
Output: 1
SIGN():
SIGN() returns the sign of a number as -1 (negative), 0 (zero), or 1 (positive).Example:
sqlCopy code
SELECT SIGN(-7) AS sign_result, SIGN(0) AS zero_result, SIGN(3) AS positive_result;
Output: -1, 0, 1
PI():
PI() returns the mathematical constant π (pi).Example:
sqlCopy code
SELECT PI() AS pi_value;
Output: 3.141592653589793
LOG():
LOG() calculates the natural logarithm of a number.Example:
sqlCopy code
SELECT LOG(10) AS natural_log;
Output: 2.302585092994046
These numeric functions in MySQL are useful for performing various calculations on numeric data types in your SQL queries.