Bird
Raised Fist0
MySQLquery~20 mins

ROUND, CEIL, FLOOR in MySQL - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Master of ROUND, CEIL, FLOOR
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate
2:00remaining
Output of ROUND function with decimals
What is the output of the following MySQL query?

SELECT ROUND(12.3456, 2) AS rounded_value;
MySQL
SELECT ROUND(12.3456, 2) AS rounded_value;
A12
B12.34
C12.346
D12.35
Attempts:
2 left
💡 Hint
ROUND rounds the number to the specified decimal places.
❓ query_result
intermediate
2:00remaining
Output of CEIL function with negative decimal
What is the output of this MySQL query?

SELECT CEIL(-3.7) AS ceil_value;
MySQL
SELECT CEIL(-3.7) AS ceil_value;
A-3
B-4
C-3.7
D-2
Attempts:
2 left
💡 Hint
CEIL returns the smallest integer greater than or equal to the number.
❓ query_result
advanced
2:00remaining
Output of FLOOR function with positive decimal
What is the output of this MySQL query?

SELECT FLOOR(7.999) AS floor_value;
MySQL
SELECT FLOOR(7.999) AS floor_value;
A7.999
B8
C7
D0
Attempts:
2 left
💡 Hint
FLOOR returns the largest integer less than or equal to the number.
🧠 Conceptual
advanced
2:00remaining
Difference between CEIL and FLOOR for negative numbers
Which statement correctly describes the difference between CEIL and FLOOR functions when applied to negative decimal numbers in MySQL?
ACEIL rounds towards zero, FLOOR rounds away from zero.
BCEIL returns the smallest integer greater than or equal to the number, FLOOR returns the largest integer less than or equal to the number.
CCEIL and FLOOR both round up for negative numbers.
DCEIL and FLOOR both round down for negative numbers.
Attempts:
2 left
💡 Hint
Think about how CEIL and FLOOR behave on negative decimals.
📝 Syntax
expert
2:00remaining
Identify the syntax error in ROUND usage
Which option contains a syntax error when using the ROUND function in MySQL?
ASELECT ROUND(15.678 1);
BSELECT ROUND(15.678, 1);
CSELECT ROUND(15.678);
DSELECT ROUND(15.678, 0);
Attempts:
2 left
💡 Hint
Check the syntax for function arguments and commas.

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