Bird
Raised Fist0
MySQLquery~5 mins

ROUND, CEIL, FLOOR in MySQL - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What does the ROUND() function do in MySQL?
The ROUND() function rounds a number to the nearest integer or to a specified number of decimal places.
Click to reveal answer
beginner
How does the CEIL() function behave?
CEIL() returns the smallest integer greater than or equal to the given number. It rounds numbers up.
Click to reveal answer
beginner
What is the purpose of the FLOOR() function?
FLOOR() returns the largest integer less than or equal to the given number. It rounds numbers down.
Click to reveal answer
beginner
How do you round the number 3.14159 to 2 decimal places using ROUND()?
Use ROUND(3.14159, 2) which returns 3.14.
Click to reveal answer
intermediate
What will CEIL(-2.3) and FLOOR(-2.3) return?
CEIL(-2.3) returns -2 (rounds up), FLOOR(-2.3) returns -3 (rounds down).
Click to reveal answer
What does ROUND(4.567, 1) return?
A4.6
B5
C4.5
D4
Which function rounds a number up to the nearest integer?
AFLOOR()
BROUND()
CCEIL()
DTRUNCATE()
What does FLOOR(7.9) return?
A0
B8
C7.9
D7
If you want to round 5.678 to the nearest integer, which function do you use?
AROUND()
BFLOOR()
CABS()
DCEIL()
What is the result of CEIL(-3.7)?
A-4
B-3
C-3.7
D-2
Explain the difference between ROUND(), CEIL(), and FLOOR() functions in MySQL.
Think about how each function treats decimal parts of numbers.
You got /3 concepts.
    How would you use ROUND() to round a number to 3 decimal places? Give an example.
    The second argument in ROUND controls decimal places.
    You got /2 concepts.

      Practice

      (1/5)
      1. Which MySQL function rounds a number to the nearest whole number or specified decimal place?
      easy
      A. CEIL
      B. ROUND
      C. FLOOR
      D. TRUNCATE

      Solution

      1. Step 1: Understand the function purpose

        ROUND changes a number to the nearest integer or decimal place, unlike CEIL or FLOOR which only round up or down.
      2. Step 2: Compare with other functions

        CEIL always rounds up, FLOOR always rounds down, TRUNCATE cuts decimals without rounding.
      3. Final Answer:

        ROUND -> Option B
      4. Quick Check:

        ROUND = nearest rounding [OK]
      Hint: ROUND = nearest number, CEIL up, FLOOR down [OK]
      Common Mistakes:
      • Confusing CEIL with ROUND
      • Thinking FLOOR rounds to nearest
      • Assuming TRUNCATE rounds
      2. Which of the following is the correct syntax to round the number 3.14159 to 2 decimal places in MySQL?
      easy
      A. ROUND(3.14159, 2)
      B. CEIL(3.14159, 2)
      C. FLOOR(3.14159, 2)
      D. ROUND(3.14159. 2)

      Solution

      1. Step 1: Check function usage

        ROUND accepts two arguments: the number and the decimal places to round to.
      2. Step 2: Identify correct syntax

        ROUND(3.14159, 2) is correct; CEIL and FLOOR do not take decimal places, and ROUND(3.14159. 2) has a syntax error with a dot instead of a comma.
      3. Final Answer:

        ROUND(3.14159, 2) -> Option A
      4. Quick Check:

        ROUND(number, decimals) syntax [OK]
      Hint: ROUND(number, decimals) uses comma, CEIL/FLOOR no decimals [OK]
      Common Mistakes:
      • Using CEIL or FLOOR with decimal places
      • Using dot instead of comma between arguments
      • Missing second argument for ROUND
      3. What is the result of the query: SELECT CEIL(4.2), FLOOR(4.8), ROUND(4.5);?
      medium
      A. 5, 4, 5
      B. 4, 4, 4
      C. 5, 5, 5
      D. 4, 5, 4

      Solution

      1. Step 1: Evaluate CEIL(4.2)

        CEIL rounds up to the next whole number, so CEIL(4.2) = 5.
      2. Step 2: Evaluate FLOOR(4.8) and ROUND(4.5)

        FLOOR rounds down, so FLOOR(4.8) = 4. ROUND rounds to nearest integer, 4.5 rounds up to 5.
      3. Final Answer:

        5, 4, 5 -> Option A
      4. Quick Check:

        CEIL=5, FLOOR=4, ROUND=5 [OK]
      Hint: CEIL up, FLOOR down, ROUND nearest (0.5 rounds up) [OK]
      Common Mistakes:
      • Thinking FLOOR(4.8) is 5
      • Rounding 4.5 down instead of up
      • Confusing CEIL and FLOOR
      4. Identify the error in this query: SELECT CEIL(5.7, 1), FLOOR(3.2), ROUND(2.718);
      medium
      A. ROUND requires two arguments
      B. FLOOR requires two arguments
      C. CEIL does not accept two arguments
      D. No error, query is correct

      Solution

      1. Step 1: Check CEIL function arguments

        CEIL only accepts one argument (the number). Passing two arguments causes an error.
      2. Step 2: Verify FLOOR and ROUND usage

        FLOOR accepts one argument, ROUND can accept one or two arguments. Both FLOOR(3.2) and ROUND(2.718) are valid.
      3. Final Answer:

        CEIL does not accept two arguments -> Option C
      4. Quick Check:

        CEIL = 1 argument only [OK]
      Hint: CEIL/FLOOR take 1 argument; ROUND can take 1 or 2 [OK]
      Common Mistakes:
      • Passing two arguments to CEIL or FLOOR
      • Assuming ROUND always needs two arguments
      • Thinking query has no errors
      5. You have a table prices with a column cost containing decimal values. You want to create a new column rounded_cost that rounds cost to the nearest integer but always rounds up if the decimal part is exactly 0.5. Which MySQL expression achieves this?
      hard
      A. ROUND(cost)
      B. IF(cost - FLOOR(cost) = 0.5, FLOOR(cost), ROUND(cost))
      C. CEIL(cost - 0.5)
      D. CEIL(cost)

      Solution

      1. Step 1: Understand rounding rules

        In MySQL, ROUND rounds to nearest integer; halfway cases (.5) round away from zero (up for positive numbers).
      2. Step 2: Select the correct expression

        CEIL(cost) always rounds up, so it rounds up when decimal part is exactly 0.5, fulfilling the requirement.
      3. Step 3: Analyze other options

        A rounds .5 up normally, but does not always round up if decimal is exactly 0.5 (it rounds to nearest). B rounds down for exactly .5, which is incorrect. D fails on .5 cases as CEIL(cost - 0.5) can round down.
      4. Final Answer:

        CEIL(cost) -> Option D
      5. Quick Check:

        CEIL(cost) always rounds up [OK]
      Hint: CEIL(cost) always rounds up, including .5 cases [OK]
      Common Mistakes:
      • Assuming ROUND always rounds .5 up as needed
      • Using conditional that rounds .5 down
      • CEIL(cost - 0.5) fails on .5 cases
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard