Math Functions
SQL has built-in math functions for calculations.
ROUND(number, decimals) - round to N decimal places:
ABS(number) - absolute value (remove negative sign):
SELECT ABS(balance) FROM accounts;Modulo (%) - remainder after division:
Arithmetic in SELECT:
You can combine math with other clauses:
Check your understanding
Which function rounds a number to 2 decimal places?
Examples run on the employees sample database. Open any of them in the playground to experiment.