Skip to main content
Module 6 · Lesson 3 of 423/57 in the course~14 min
Module lessons (3/4)

Numeric Functions

Lesson preview5 hands-on exercises readySQL Course · Module 6 — Built-in Functions

ROUND, CEIL, FLOOR, ABS, MOD, and integer vs. decimal division.

What you'll learn in this lesson

  • Round and transform numbers with ROUND, CEIL, FLOOR, ABS, and MOD.
  • Avoid the silent trap of integer division (INTEGER / INTEGER).
  • Choose NUMERIC instead of DOUBLE PRECISION for exact monetary amounts and calculations.

Overview

Numerical calculations in SQL hide a pitfall capable of resetting entire KPI reports without any error: in PostgreSQL dividing two integers always produces a truncated integer result! Learning about decimal types and rounding is essential for reliable statistics and amounts.

See how WHERE first excludes ineligible rows (e.g. orders not yet delivered) so that the numeric and ROUND(...) functions in SELECT only operate on valid data:

Sections covered in this lesson

  1. 11. Mental Model: Exact Arithmetic vs Integer Division
  2. 22. Progressive & Annotated Examples
  3. 33. Interactive Laboratory: Calculations after Filtering and Grouping
  4. 44. Diagnostic Verification (Quiz)
  5. 55. Progressive Practical Laboratory
Pro Lesson · Module 6 — Built-in Functions

Unlock "Numeric Functions" and the full SQL Course curriculum

ROUND, CEIL, FLOOR, ABS, MOD, and integer vs. decimal division.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in SQL Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.