Module lessons (3/4)
Numeric 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, andMOD. - Avoid the silent trap of integer division (
INTEGER / INTEGER). - Choose
NUMERICinstead ofDOUBLE PRECISIONfor 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
- 11. Mental Model: Exact Arithmetic vs Integer Division
- 22. Progressive & Annotated Examples
- 33. Interactive Laboratory: Calculations after Filtering and Grouping
- 44. Diagnostic Verification (Quiz)
- 55. Progressive Practical Laboratory
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.