MySQL Numeric Functions are built-in functions used to perform calculations, rounding, absolute values, random numbers, and mathematical operations on numeric data. They are commonly used in reports, analytics, billing systems, and financial calculations.
Numeric functions take numeric input and return a calculated numeric result. They can be applied directly to values or table columns.
// Absolute value removes negative sign
SELECT ABS(-25);
// Rounds number to nearest integer
SELECT ROUND(12.6);
// Always rounds up to next integer
SELECT CEILING(4.2);
// Always rounds down to previous integer
SELECT FLOOR(9.9);
// Returns remainder of division (10 divided by 3)
SELECT MOD(10,3);
// Power calculation (2 to the power of 3)
SELECT POWER(2,3);
// Square root of a number
SELECT SQRT(81);
// Generates random number between 0 and 1
SELECT RAND();
// Truncate decimal without rounding
SELECT TRUNCATE(12.99, 0);
ABS(-25) → 25ROUND(12.6) → 13CEILING(4.2) → 5FLOOR(9.9) → 9MOD(10,3) → 1POWER(2,3) → 8SQRT(81) → 9RAND() → 0.843... (Random decimal value)TRUNCATE(12.99, 0) → 12ROUND() when displaying prices or averages to keep data clean.TRUNCATE() when decimals must be removed strictly without rounding up.WHERE clauses carefully for filtering data.RAND().MOD() to find even and odd numbers (e.g., id % 2 = 0).