0
0
SQLquery~10 mins

ROUND, CEIL, FLOOR in SQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - ROUND, CEIL, FLOOR
Start with a number
ROUND
Return result
Start with a number, pick one of the functions ROUND, CEIL, or FLOOR, then get the rounded result accordingly.
Execution Sample
SQL
SELECT ROUND(4.3), CEIL(4.3), FLOOR(4.7);
This query rounds 4.3 to nearest integer, rounds 4.3 up, and rounds 4.7 down.
Execution Table
StepFunctionInputOperationResult
1ROUND4.3Round to nearest integer4
2CEIL4.3Round up to next integer5
3FLOOR4.7Round down to previous integer4
4ENDAll functions executedResults: 4, 5, 4
💡 All functions processed, results returned.
Variable Tracker
VariableStartAfter ROUNDAfter CEILAfter FLOORFinal
Input Number4.3 / 4.3 / 4.74.34.34.7unchanged
ROUND ResultN/A4N/AN/A4
CEIL ResultN/AN/A5N/A5
FLOOR ResultN/AN/AN/A44
Key Moments - 2 Insights
Why does ROUND(4.3) give 4 but CEIL(4.3) gives 5?
ROUND rounds to the nearest integer, so 4.3 becomes 4. CEIL always rounds up to the next integer, so 4.3 becomes 5. See execution_table rows 1 and 2.
Why does FLOOR(4.7) give 4 instead of 5?
FLOOR always rounds down to the previous integer, so 4.7 becomes 4. See execution_table row 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the result of CEIL(4.3)?
A4
B5
C3
D6
💡 Hint
Check execution_table row 2 under Result column.
At which step does the function round down?
AStep 3
BStep 1
CStep 2
DStep 4
💡 Hint
Look for FLOOR function in execution_table.
If input was 4.5, what would ROUND(4.5) return?
A6
B4
C5
D3
💡 Hint
ROUND rounds to nearest integer; 4.5 rounds up to 5.
Concept Snapshot
ROUND(number): rounds to nearest integer.
CEIL(number): rounds up to next integer.
FLOOR(number): rounds down to previous integer.
Use these to control decimal rounding in SQL queries.
Full Transcript
This lesson shows how SQL functions ROUND, CEIL, and FLOOR work. Starting with a number, ROUND rounds it to the nearest whole number. CEIL always rounds up to the next whole number, even if the decimal is small. FLOOR always rounds down to the previous whole number. For example, ROUND(4.3) is 4, CEIL(4.3) is 5, and FLOOR(4.7) is 4. These functions help control how decimals are handled in your data queries.