Example 1
Round, floor, and ceil the unit cost of each order
100.00 / 3 = 33.333...: ROUND to 2 places gives 33.33, FLOOR discards the fraction to give 33, CEIL bumps up to 34. 50.00 / 4 = 12.5: ROUND to 2 places gives 12.50 (already at 2 decimal places), FLOOR gives 12, CEIL gives 13. 75.00 / 10 = 7.5: same logic as 12.5.
CREATE TABLE orders (id INT, total DECIMAL(10, 2), qty INT);
INSERT INTO
orders
VALUES
(1, 100.00, 3),
(2, 50.00, 4),
(3, 75.00, 10);SELECT
id,
ROUND(total / qty, 2) AS unit_cost,
FLOOR(total / qty) AS floor_cost,
CEIL(total / qty) AS ceil_cost
FROM
orders
ORDER BY
id;| id | unit_cost | floor_cost | ceil_cost |
|---|---|---|---|
| 1 | 33.33 | 33 | 34 |
| 2 | 12.50 | 12 | 13 |
| 3 | 7.50 | 7 | 8 |
CREATE TABLE orders (id INT, total DECIMAL(10, 2), qty INT);
INSERT INTO
orders
VALUES
(1, 100.00, 3),
(2, 50.00, 4),
(3, 75.00, 10);SELECT
id,
ROUND(total / qty, 2) AS unit_cost,
FLOOR(total / qty) AS floor_cost,
CEILING(total / qty) AS ceil_cost
FROM
orders
ORDER BY
id;| id | unit_cost | floor_cost | ceil_cost |
|---|---|---|---|
| 1 | 33.33 | 33.00 | 34.00 |
| 2 | 12.50 | 12.00 | 13.00 |
| 3 | 7.50 | 7.00 | 8.00 |
CREATE TABLE orders (id INT, total DECIMAL(10, 2), qty INT);
INSERT INTO
orders
VALUES
(1, 100.00, 3),
(2, 50.00, 4),
(3, 75.00, 10);SELECT
id,
ROUND(total / qty, 2) AS unit_cost,
FLOOR(total / qty) AS floor_cost,
CEIL(total / qty) AS ceil_cost
FROM
orders
ORDER BY
id;| id | unit_cost | floor_cost | ceil_cost |
|---|---|---|---|
| 1 | 33.33 | 33 | 34 |
| 2 | 12.5 | 12 | 13 |
| 3 | 7.5 | 7 | 8 |
SQL Server uses CEILING and preserves the DECIMAL scale on FLOOR/CEILING results. SQLite returns real values. Numeric values are identical across all engines.