0PricingLogin
SQL Academy · Lesson

Rounding and Truncating

ROUND, CEIL, FLOOR and TRUNC.

Why Rounding Matters

When working with numbers in SQL, you often get results with many decimal places. For example, dividing 10 by 3 gives 3.3333333...

SQL provides built-in functions to control how many decimal places you display or store: ROUND, CEIL, FLOOR, and TRUNC. These are essential for presenting clean financial figures, measurements, and statistics.

SELECT 10.0 / 3.0 AS raw_result;

ROUND: Basic Usage

The ROUND() function rounds a number to a specified number of decimal places. It follows standard rounding rules: digits 5 and above round up, digits below 5 round down.

The syntax is: ROUND(number, decimal_places). If you omit the second argument, it rounds to the nearest whole number.

SELECT
  ROUND(3.14159, 2) AS two_decimals,
  ROUND(3.14159, 0) AS zero_decimals,
  ROUND(3.14159)    AS no_arg;

All lessons in this course

  1. Arithmetic and Operators
  2. Rounding and Truncating
  3. Integer vs Decimal Division
  4. Useful Math Functions
← Back to SQL Academy