Numeric Functions Deep Dive
Numeric Functions Deep Dive — Comprehensive guide to numeric functions — ROUND, CEIL, FLOOR, POWER, MOD, TRUNCATE, and more. The guide walks through Rounding Functions, CEIL() & FLOOR(), POWER(), SQRT() & EXP(), MOD() & Remainder, Absolute, Sign & Precision. ROUND(value, decimals) rounds to the specified decimal places. ROUND(3.14159, 2) returns 3.14. ROUND follows standard rounding (half up in most databases). TRUNCATE(value, decimals) truncates without rounding — TRUNCATE(3.14159, 2) returns 3.14. Use TRUNCATE when you want to discard extra precision without rounding, such as for display purposes. CEIL(value) rounds UP to the nearest integer. CEIL(3.1) = 4, CEIL(-3.1) = -3. FLOOR(value) rounds DOWN to the nearest integer. FLOOR(3.9) = 3, FLOOR(-3.9) = -4. CEIL and FLOOR always return integers. Use CEIL for billing (round up partial hours) and FLOOR for truncating decimal places in pricing calculations. The guide is organized into 5 sections that build on each other, each pairing a prose explanation with real SQL you can run as-is.