Using ROUND, CEIL, and FLOOR Functions in SQL
📖 Scenario: You work for an online store that tracks product prices with decimals. You want to prepare a report that shows prices rounded in different ways for better display and analysis.
🎯 Goal: Create SQL queries that use the ROUND, CEIL, and FLOOR functions to transform product prices.
📋 What You'll Learn
Create a table called
products with columns id (integer) and price (decimal).Insert exactly these rows into
products: (1, 10.75), (2, 23.40), (3, 5.99), (4, 100.01).Write a query that selects
id and the price rounded to the nearest whole number using ROUND(price).Write a query that selects
id and the price rounded up to the next whole number using CEIL(price).Write a query that selects
id and the price rounded down to the previous whole number using FLOOR(price).💡 Why This Matters
🌍 Real World
Online stores and financial reports often need to display prices rounded in different ways for clarity and customer understanding.
💼 Career
Knowing how to use ROUND, CEIL, and FLOOR in SQL helps database analysts and developers prepare clean, user-friendly reports and data summaries.
Progress0 / 4 steps