Using ROUND, CEIL, and FLOOR Functions in MySQL
📖 Scenario: You work at an online store that records product prices with many decimal places. You want to prepare a simple report showing prices rounded in different ways for easy reading.
🎯 Goal: Create a MySQL table with product prices, then write queries using ROUND, CEIL, and FLOOR functions to show prices rounded normally, rounded up, and rounded down.
📋 What You'll Learn
Create a table named
products with columns id (integer) and price (decimal).Insert exactly these three rows: (1, 12.345), (2, 7.891), (3, 15.678).
Write a SELECT query that shows
id and price_rounded using ROUND(price, 2).Write a SELECT query that shows
id and price_ceil using CEIL(price).Write a SELECT query that shows
id and price_floor using FLOOR(price).💡 Why This Matters
🌍 Real World
Rounding prices is common in billing systems, reports, and user displays to make numbers easier to read and understand.
💼 Career
Database developers and analysts often use rounding functions to prepare data for reports, dashboards, and financial calculations.
Progress0 / 4 steps