Numeric functions allow you to perform mathematical operations on column values directly in SQL. This eliminates the need to pull raw numbers into application code just to round or calculate them.
Key Numeric Functions
- ROUND(n, d): Rounds n to d decimal places
- CEIL(n) / FLOOR(n): Rounds up or down to the nearest integer
- ABS(n): Absolute value
- MOD(n, m): Remainder of n divided by m
- POWER(n, e): Raises n to the power e
- SQRT(n): Square root
- TRUNCATE(n, d): Truncates (does not round) to d decimals
Financial Calculations
ROUND is particularly important in financial applications where currency values must be presented to exactly two decimal places. Using TRUNCATE instead of ROUND can lead to small systematic errors in totals.