Numeric Functions in SQL | Number Functions | Floor | Round | Ceiling | Abs | Square | Square Root |Logarithm | Trigonometric
🔢 What Are Numerical Functions?
Numerical functions in SQL are built-in operations that let you perform mathematical calculations directly on numeric data stored in your database. They’re super handy for analytics, reporting, and transforming raw data into meaningful insights.
⚡ Common SQL Numerical Functions
ABS
Returns the absolute value of a number.
Example: ABS(-15) → 15
CEILING
Rounds a number up to the nearest integer.
Example: CEILING(4.2) → 5
FLOOR
Rounds a number down to the nearest integer.
Example: FLOOR(4.8) → 4
ROUND
Rounds a number to a specified number of decimal places.
Example: ROUND(3.14159, 2) → 3.14
POWER
Raises a number to a given power.
Example: POWER(2, 3) → 8
SQRT
Returns the square root of a number.
Example: SQRT(16) → 4
SIGN
Returns -1, 0, or 1 depending on whether the number is negative, zero, or positive.
Example: SIGN(-25) → -1
RAND
Generates a random number between 0 and 1.
Example: RAND() → 0.7345 (varies each time)