FLOOR() Function in SQL
Introduction
FLOOR is a numeric SQL function that returns the greatest integer less than or equal to a number. In practical language, it finds the integer boundary in the direction of negative infinity. The floor of 12.8 is 12, while the floor of -12.8 is -13. That negative example is essential because FLOOR is often described too loosely as a function that removes decimals.
SELECT FLOOR(12.8) AS positive_floor,
FLOOR(-12.8) AS negative_floor;
-- Common results: 12 and -13
FLOOR is useful when a calculation asks how many complete groups, fully filled containers, finished time units, or lower-bound buckets exist. It also supports reporting bands, allocation analysis, threshold calculations, and transformations to a chosen step size. Correct use requires more than memorizing syntax: developers must understand negative values, preserve fractional division, select appropriate data types, handle NULL and zero denominators, and review how expressions affect indexes.
Syntax and Accepted Expressions
The standard form accepts one numeric expression. That expression may be a literal, column, arithmetic calculation, aggregate result, CASE expression, or another compatible numeric function.
FLOOR(numeric_expression)
A basic query is straightforward.
SELECT FLOOR(25.9) AS lower_integer;
-- Result: 25
The function does not modify stored data unless its result is used in an INSERT or UPDATE. In an ordinary SELECT, it returns a calculated value for each evaluated row.
The Mathematical Definition
For a value x, FLOOR(x) is the greatest integer that is less than or equal to x. Consider 12.7. Integers not greater than it include 12, 11, 10, and all smaller integers. The greatest member of that set is 12, so FLOOR(12.7) is 12.
This definition works without special cases. An existing integer is its own floor. A positive fraction between zero and one has a floor of zero. A negative fraction between negative one and zero has a floor of negative one. Thinking in inequalities is more reliable than thinking only about removing digits after a decimal point.
FLOOR Moves Toward Negative Infinity
The clearest mental model is movement along a number line toward negative infinity until an integer boundary is reached. For 8.4, that boundary is 8. For -8.4, it is -9. Although -8 is closer to zero, it is greater than the input and therefore cannot be its floor.
FLOOR(8.4) = 8
FLOOR(-8.4) = -9
The word "down" refers to numeric order, not visual placement or removal of the fractional text. On a standard number line, -9 is lower than -8.4, while -8 is higher.
Positive Decimal Values
Every positive value between two adjacent integers has the lower integer as its floor. The size of the fractional part does not create a halfway rule.
SELECT FLOOR(10.01),
FLOOR(10.49),
FLOOR(10.50),
FLOOR(10.99);
-- Each commonly returns 10.
This differs from ordinary nearest-value rounding. FLOOR(10.99) remains 10 even though 10.99 is much closer to 11.
Whole Numbers and Zero
An integer already satisfies the definition and remains unchanged. The same applies when an exact decimal value happens to represent a whole number.
SELECT FLOOR(25) AS integer_value,
FLOOR(25.0) AS decimal_integer,
FLOOR(0) AS zero_value,
FLOOR(-10) AS negative_integer;
-- Results: 25, 25, 0, -10
FLOOR does not always subtract one. It changes a number only when that number lies between integer boundaries.
Negative Decimal Values
Negative values are where misconceptions appear. The greatest integer less than or equal to -12.3 is -13. The integer -12 is greater than -12.3, so it does not satisfy the less-than-or-equal requirement.
SELECT FLOOR(-12.3) AS first_result,
FLOOR(-12.9) AS second_result;
-- Both commonly return -13.
When business data can include refunds, temperature changes, coordinate offsets, losses, adjustments, or negative balances, this behavior must be included in requirements and tests.
Values Around Zero
Small magnitudes make the boundary behavior easy to see.
| Input | FLOOR result | Reason |
|---|---|---|
| 0 | 0 | Already an integer |
| 0.001 | 0 | Zero is the greatest integer not above it |
| 0.999 | 0 | The value has not reached one |
| -0.001 | -1 | Zero is greater than the input |
| -0.999 | -1 | Negative one is the lower boundary |
| -1.001 | -2 | The value is below negative one |
Boundary tests should include exact integers and values immediately on both sides. Such tests catch sign mistakes, floating-point surprises, and incorrect assumptions about truncation.
Using FLOOR with Columns
FLOOR can be applied to each value in a numeric column. Keeping the original and calculated values together makes the transformation visible during development and review.
SELECT product_name,
rating,
FLOOR(rating) AS rating_floor
FROM products;
For ratings 4.8, 3.9, and 4.2, the floor values are 4, 3, and 4. A column alias should explain what the result means rather than hide the directional operation behind a vague name such as rounded_rating.
Using FLOOR with Arithmetic Expressions
The input can be the result of arithmetic. SQL evaluates the inner expression first and applies FLOOR afterward.
SELECT order_item_id,
price,
quantity,
FLOOR(price * quantity) AS lower_whole_amount
FROM order_items;
If price is 10.25 and quantity is 3, the expression produces 30.75 and FLOOR returns 30. Use this only when the business rule truly requires a lower integer boundary. It is normally unsuitable for monetary totals because it discards part of the value in a directional way.
Complete Groups
One of the strongest use cases is counting groups that can be filled completely. Divide the available quantity by the group capacity and take the floor of the ratio.
complete_groups = FLOOR(available_quantity / group_size)
If 25 students are arranged into teams of four, six complete teams can be formed and one student remains. The calculation answers how many full groups exist, not how many groups are required to include everyone.
SELECT FLOOR(25.0 / 4) AS complete_teams;
-- Result: 6
Full Boxes and Remaining Items
Suppose inventory contains 53 items and one full box holds 10. FLOOR returns five full boxes. A remainder operation returns the three loose items.
SELECT FLOOR(53.0 / 10) AS full_boxes,
MOD(53, 10) AS remaining_items;
Remainder syntax differs among databases; some use MOD, while others also support the percent operator. Keep the quotient and remainder based on the same validated capacity so the two values reconcile with the original quantity.
Integer Division Pitfall
Division semantics depend on operand types and DBMS rules. When both operands are integers, some systems produce an integer quotient before FLOOR is called. For positive complete-group calculations, the final value may happen to look correct, but the intermediate fraction and remainder information have already been lost.
-- Make decimal division explicit
SELECT FLOOR(25.0 / 4) AS complete_teams;
-- Portable intent with an explicit exact type
SELECT FLOOR(
CAST(student_count AS DECIMAL(19, 4)) /
NULLIF(team_size, 0)
) AS complete_teams
FROM class_summary;
Explicit typing documents intent and becomes important when the formula is later reused with negative values, percentages, or additional calculations.
FLOOR and CEIL Answer Different Questions
With 53 items and capacity 10, FLOOR(53 / 10) gives five complete containers. CEIL(53 / 10) gives six containers required to hold all items. Both answers are correct for different questions.
| Requirement | Operation | Result for 53 / 10 |
|---|---|---|
| Completely filled boxes | FLOOR | 5 |
| Boxes required for every item | CEIL or CEILING | 6 |
| Loose items after full boxes | Remainder | 3 |
Requirements should use precise words such as complete, full, required, remaining, started, or finished. Choosing a function before clarifying the question creates apparently reasonable but operationally wrong answers.
Completed Time Units
FLOOR can express fully completed time units when the input is a nonnegative duration. A duration of 7.8 hours contains seven complete hours, and 12.75 days contains twelve complete days.
SELECT FLOOR(hours_elapsed) AS completed_hours,
FLOOR(days_elapsed) AS completed_days
FROM process_duration;
Do not approximate age or calendar periods by dividing days into decimal years. Months have different lengths, leap years exist, and time zones affect boundaries. Use date-aware functions for calendar calculations, then apply floor only if a documented fractional result genuinely needs a lower whole-unit boundary.
Complete Batches
For 4,501 records and a batch size of 1,000, four batches can be completely filled and 501 records remain. If the process must handle every record, five batches are required, so the scheduler would use CEIL rather than FLOOR.
SELECT FLOOR(4501.0 / 1000) AS complete_batches,
MOD(4501, 1000) AS remaining_records,
CEIL(4501.0 / 1000) AS batches_required;
Operational dashboards should distinguish completed, full, scheduled, and required batches. Using one label for all four creates confusion when the final partial batch is in progress.
Inventory and Packaging
A warehouse can calculate full cases from on-hand quantity and units per case. Defensive division prevents an invalid capacity from causing a runtime error.
SELECT product_id,
quantity,
units_per_case,
FLOOR(
CAST(quantity AS DECIMAL(19, 4)) /
NULLIF(units_per_case, 0)
) AS full_cases
FROM inventory;
A NULL result for zero capacity should trigger data-quality handling, not silently become zero full cases. Zero capacity means the denominator is invalid or missing, not that packing is impossible with a known valid package.
FLOOR with Aggregate Functions
Aggregate results can be floored after the aggregation is complete. FLOOR(AVG(score)) returns the lower integer boundary of the average, while AVG(FLOOR(score)) first changes every score and then averages those changed values. These expressions are generally not equivalent.
SELECT department,
AVG(score) AS exact_average,
FLOOR(AVG(score)) AS average_floor,
AVG(FLOOR(score)) AS average_of_floors
FROM assessment
GROUP BY department;
Apply the function at the stage described by the requirement. Preserve the exact aggregate for audit and analysis even when a report also displays a whole-number floor.
FLOOR Versus ROUND
FLOOR always chooses the integer boundary toward negative infinity. ROUND selects a nearest value according to the database's rounding rules and requested precision. For 12.2 both may produce 12, but for 12.8 FLOOR produces 12 while ordinary ROUND produces 13.
| Input | FLOOR | Typical ROUND to integer |
|---|---|---|
| 12.3 | 12 | 12 |
| 12.8 | 12 | 13 |
| -12.3 | -13 | -12 |
| -12.8 | -13 | -13 |
Tie handling for ROUND can vary by product, type, and configuration. Verify the target database rather than assuming every system treats .5 identically.
FLOOR Versus Truncation
For positive values, FLOOR and truncation toward zero often look the same. Both turn 12.9 into 12. For negative values, they diverge: FLOOR(-12.9) is -13, while truncation toward zero usually produces -12.
-- Conceptual comparison
FLOOR(-12.9) = -13
TRUNCATE_TOWARD_ZERO = -12
The exact truncation function and syntax vary by DBMS. Never replace one operation with the other merely because tests contain only positive data.
FLOOR Versus CAST to an Integer
Converting a decimal to an integer is not a portable substitute for FLOOR. A database may truncate, round, reject an out-of-range value, or return a different integer type depending on the source and target types. Negative values again reveal the difference.
SELECT FLOOR(-7.8) AS defined_lower_boundary;
-- Do not assume this has identical semantics:
SELECT CAST(-7.8 AS INTEGER) AS converted_value;
Use FLOOR to express a mathematical boundary and CAST to express a type conversion. If both are needed, apply them deliberately and confirm the result type.
Useful Mathematical Properties
FLOOR is idempotent: applying it more than once does not change the result. After the first call produces an integer boundary, a second call receives an integer and returns that same value. Therefore, FLOOR(FLOOR(x)) equals FLOOR(x). Repeated calls usually add noise rather than protection.
SELECT FLOOR(FLOOR(18.75)) AS repeated_floor;
-- Result: 18, which is also FLOOR(18.75)
The function is also monotonic. If a is less than or equal to b, then FLOOR(a) is less than or equal to FLOOR(b). This property supports ordered buckets and boundary reasoning, although multiple source values can share one result. FLOOR is therefore not reversible: knowing that a value has floor 18 reveals only that the original exact value was at least 18 and below 19.
FLOOR(x) is always less than or equal to x, and the difference x - FLOOR(x) is at least zero and below one for finite real values. That difference can represent a fractional remainder for a unit-sized interval. For custom group sizes, use validated division and a remainder calculation rather than assuming this fractional difference has the same physical unit as the source.
These properties help reviewers simplify expressions and verify range rewrites. They do not override SQL concerns such as NULL propagation, approximate floating-point storage, overflow, or database-specific return types.
FLOOR Does Not Control Ordinary Decimal Precision
FLOOR(12.789) returns 12, not 12.78. If the requirement is conventional rounding to two decimal places, use the database's supported precision form of ROUND. If the requirement is specifically to choose the lower hundredth, scale the value, apply FLOOR, and scale it back.
-- Conventional rounding to two decimals
SELECT ROUND(12.789, 2); -- commonly 12.79
-- Mathematical floor to two decimals
SELECT FLOOR(12.789 * 100) / 100.0; -- 12.78
For negative values, floor-to-precision still moves toward negative infinity. FLOOR(-12.781 * 100) / 100.0 is -12.79, not -12.78. This is why the operation must not be described as cutting off extra digits.
Flooring to a Chosen Step Size
The scale-floor-rescale pattern works for decimal places and larger intervals. To floor a positive amount to the nearest lower ten, divide by ten, apply FLOOR, and multiply by ten. For a lower hundred, use one hundred.
SELECT FLOOR(127.0 / 10) * 10 AS lower_ten,
FLOOR(1275.0 / 100) * 100 AS lower_hundred;
-- Results: 120 and 1200
A general formula is FLOOR(value / step) * step, where step is positive and nonzero. Validate units and step size. With negative inputs, the result is the next step toward negative infinity, so -127 floored to a step of ten becomes -130.
Creating Numeric Buckets
FLOOR can assign observations to equal-width buckets. For a bucket width of 10, the expression below returns the lower boundary of each bucket.
SELECT FLOOR(price / 10.0) * 10 AS price_bucket,
COUNT(*) AS product_count
FROM products
GROUP BY FLOOR(price / 10.0) * 10
ORDER BY price_bucket;
Prices from 20.00 through values below 30.00 fall into bucket 20. Document whether boundary values are inclusive and how negative prices are treated. A refund of -0.01 falls into bucket -10 under mathematical floor, which may or may not match the reporting requirement.
Bucket Labels and Boundaries
A numeric lower boundary is often clearer than a formatted label, but reports may need a range such as "20 to under 30." Calculate boundaries first and format labels in a presentation layer when possible.
WITH price_buckets AS (
SELECT product_id,
FLOOR(price / 10.0) * 10 AS bucket_start
FROM products
)
SELECT bucket_start,
bucket_start + 10 AS bucket_end_exclusive,
COUNT(*) AS product_count
FROM price_buckets
GROUP BY bucket_start
ORDER BY bucket_start;
Using an exclusive upper boundary avoids overlap between adjacent ranges. Store or communicate the bucket width and currency so consumers can interpret the result correctly.
NULL Handling
FLOOR(NULL) normally returns NULL because the numeric input is unknown. NULL does not mean zero, a blank string, or an absent fractional part.
SELECT FLOOR(NULL); -- normally NULL
COALESCE can provide a replacement value, but only when the domain explicitly defines missing data as that value.
SELECT FLOOR(COALESCE(amount, 0)) AS amount_floor
FROM payments;
For financial or measurement data, converting missing values to zero can hide incomplete records and distort aggregates. It is often better to return NULL and expose a separate data-quality count.
Zero, Negative, and NULL Divisors
Complete-group formulas require a positive group size. Division by zero is invalid, a negative capacity usually violates the domain, and NULL means the capacity is unknown.
SELECT item_id,
CASE
WHEN units_per_case > 0 THEN
FLOOR(quantity * 1.0 / units_per_case)
ELSE NULL
END AS full_cases
FROM inventory;
Enforce positive capacity with constraints where possible and validate it at API boundaries. A CASE expression can protect a reporting query, but it should not become a substitute for correcting invalid master data.
Negative Quantities and Business Meaning
Mathematically, FLOOR works perfectly with negative quantities. Operationally, a negative stock balance, refund, or adjustment may need different interpretation. For example, FLOOR(-2.1 / 1) produces -3, which can overstate the magnitude if a report expects two complete returned units and one partial unit.
Define whether the system needs mathematical floor, truncation toward zero, an absolute magnitude, or separate debit and credit calculations. Do not force signed operational data through a complete-group formula designed only for nonnegative quantities.
Exact and Approximate Numeric Types
DECIMAL and NUMERIC types represent exact base-10 values within their declared precision and scale. FLOAT and REAL commonly store binary approximations. An approximate result expected to equal 10 can be stored slightly below 10, causing FLOOR to return 9 unexpectedly.
-- Prefer an exact type for contractual boundaries
SELECT FLOOR(
CAST(calculated_amount AS DECIMAL(19, 6))
) AS amount_floor
FROM billing_calculation;
Casting after approximation does not always restore the intended source value. Choose exact types early for currency, billed units, quotas, and compliance thresholds. When measurements are inherently approximate, define tolerances rather than adding an unexplained epsilon.
Return Types and Overflow
Although the mathematical result is an integer, the SQL return type is product-specific and may depend on the input type. Some systems return a numeric value with scale zero; others return a type derived from the argument. A later cast into a narrow integer can overflow even when FLOOR itself succeeds.
SELECT FLOOR(very_large_measurement) AS lower_boundary
FROM telemetry_summary;
Check official behavior for every supported database and driver. Test maximum magnitudes, application deserialization, export tools, and report formatting. Avoid assuming that a zero-scale decimal is automatically a 32-bit integer.
Database Support and Portability
MySQL, PostgreSQL, SQL Server, and Oracle all provide FLOOR, but details around accepted types, return types, implicit conversion, division, aliases, and error behavior can differ.
| Database | Typical example | Portability note |
|---|---|---|
| MySQL | SELECT FLOOR(12.8); | Review input and result type behavior |
| PostgreSQL | SELECT FLOOR(12.8); | Overloads depend on numeric type |
| SQL Server | SELECT FLOOR(12.8); | Return type follows documented type rules |
| Oracle | SELECT FLOOR(12.8) FROM dual; | DUAL is commonly used for literal examples |
Portability testing must cover more than function spelling. Confirm decimal division, NULL handling, overflow, prepared-statement parameter types, result metadata, and behavior at integer boundaries.
FLOOR in WHERE Predicates
Applying FLOOR directly to an indexed column can prevent an ordinary index seek because the database must calculate a result for rows before comparing it.
SELECT product_id, price
FROM products
WHERE FLOOR(price) = 99;
For exact numeric values, the mathematical condition FLOOR(x) = n corresponds to n <= x AND x < n + 1. The range below often expresses the same positive-price rule more efficiently.
SELECT product_id, price
FROM products
WHERE price >= 99
AND price < 100;
The identity also works for negative integer targets: FLOOR(x) = -3 corresponds to -3 <= x and x < -2. Verify NULL behavior, data type, collation-independent numeric comparison, and actual execution plans before rewriting production queries.
Expression Indexes and Generated Columns
If filtering or grouping by the same floor expression is a frequent, stable requirement, some databases support an expression index or generated column. Syntax and determinism rules vary.
-- Conceptual syntax; verify the target DBMS
ALTER TABLE products
ADD price_bucket DECIMAL(19, 2)
GENERATED ALWAYS AS (FLOOR(price / 10.0) * 10);
CREATE INDEX ix_products_price_bucket
ON products(price_bucket);
Generated values add storage and maintenance cost, and changing bucket width may require schema work. Use them for stable domain concepts, not every ad hoc report.
Ordering and Grouping Behavior
Ordering by FLOOR(value) sorts rows by integer bands, not by the original values. Rows within a band can appear in an unspecified order unless additional keys are included.
SELECT measurement_id,
measured_value,
FLOOR(measured_value) AS value_band
FROM measurements
ORDER BY FLOOR(measured_value),
measured_value,
measurement_id;
The original value and stable identifier make the output deterministic. This matters for pagination, exports, and regression tests.
Worked Warehouse Example
Assume a facility has 1,275 units, each full case holds 24, and each pallet holds 30 full cases. FLOOR(1275 / 24) gives 53 full cases with three loose units. FLOOR(53 / 30) gives one completely filled pallet, leaving 23 full cases outside that full pallet.
WITH case_count AS (
SELECT product_id,
quantity,
units_per_case,
cases_per_pallet,
FLOOR(quantity * 1.0 / units_per_case) AS full_cases,
MOD(quantity, units_per_case) AS loose_units
FROM inventory
)
SELECT product_id,
full_cases,
loose_units,
FLOOR(full_cases * 1.0 / cases_per_pallet)
AS full_pallets,
MOD(full_cases, cases_per_pallet)
AS cases_after_full_pallets
FROM case_count;
This report measures complete packaging at each level. A shipping plan would likely use CEIL to determine all cases and pallets required, so keep fulfillment demand separate from full-container inventory.
Worked Pricing Bucket Example
A retailer wants $25 reporting bands. Prices from 0 through values below 25 belong to band 0; prices from 25 through values below 50 belong to band 25. The formula is FLOOR(price / 25) multiplied by 25.
WITH categorized AS (
SELECT product_id,
price,
FLOOR(price / 25.0) * 25 AS band_start
FROM products
WHERE price IS NOT NULL
)
SELECT band_start,
band_start + 25 AS band_end_exclusive,
COUNT(*) AS products,
MIN(price) AS lowest_price,
MAX(price) AS highest_price
FROM categorized
GROUP BY band_start
ORDER BY band_start;
Filtering NULL explicitly separates missing prices from the zero band. If negative prices are allowed, document their bucket labels and confirm that mathematical floor is the intended classification rule.
Auditing and Reconciliation
Calculations used for packaging, billing, quotas, or compliance should retain the source value, divisor or step, exact ratio, floor result, units, rule version, and calculation time. Without those inputs, reviewers cannot reproduce the output.
SELECT calculation_id,
source_quantity,
group_size,
source_quantity / group_size AS raw_ratio,
FLOOR(source_quantity / group_size) AS complete_groups,
rule_version,
calculated_at
FROM grouping_audit;
Preserve manual overrides separately with reason and approver. Reconciliation should confirm that complete_groups * group_size + remainder equals the original nonnegative integer quantity.
Testing Strategy
A strong test set includes positive fractions, negative fractions, exact integers, zero, NULL, values immediately around zero, values immediately around every important boundary, maximum supported magnitudes, exact decimals, approximate floats, integer division, decimal division, zero divisors, negative divisors, and type conversions.
Representative cases include 0.001, 0.999, 1.000, 1.001, -0.001, -0.999, -1.000, and -1.001. Test both the numeric result and returned SQL type. For business workflows, verify complete groups, remainder reconciliation, bucket membership, exports, API serialization, and results on every supported database.
Common Mistakes
The most frequent mistake is describing FLOOR as decimal removal. That explanation fails for negative inputs. Other mistakes include using FLOOR when the requirement asks for all units required, confusing it with ROUND, applying it to money without a policy, losing fractions through integer division, converting NULL to zero without justification, and allowing zero or negative capacities.
Performance mistakes include wrapping indexed columns in FLOOR without examining plans and repeating expensive expressions across SELECT, GROUP BY, and ORDER BY. Data mistakes include mixing units, using approximate floating point at contractual boundaries, casting into narrow integers, and labeling a lower boundary as an ordinary rounded value.
Best-Practice Checklist
- Use the definition: greatest integer less than or equal to the input.
- Think toward negative infinity, especially for negative values.
- Clarify whether the requirement asks for complete units or all units required.
- Preserve decimal division when the fractional ratio matters.
- Require a positive, nonzero group size where the domain demands it.
- Keep numerator, denominator, step, and result units explicit.
- Use exact numeric types for financial and contractual boundaries.
- Do not substitute CAST, truncation, or ROUND for FLOOR.
- Review return types, precision, and overflow before downstream casts.
- Prefer equivalent range predicates when they improve index use.
- Audit source values, rules, results, and manual overrides.
- Test positive, negative, zero, NULL, and boundary values on each DBMS.
Interview Questions and Answers
What does FLOOR return? It returns the greatest integer less than or equal to the numeric input.
What does FLOOR(12.9) return? It returns 12 because 12 is the lower integer boundary.
What does FLOOR(-12.9) return? It returns -13 because the function moves toward negative infinity.
What happens when the input is already an integer? It remains unchanged.
How does FLOOR differ from CEIL? FLOOR selects the integer boundary toward negative infinity; CEIL selects the boundary toward positive infinity.
How does FLOOR differ from ROUND? FLOOR always chooses the lower mathematical boundary, while ROUND selects according to a nearest-value rule and precision.
Is FLOOR the same as truncation? No. They may match for positive values but differ for negative fractions.
When is FLOOR useful? It is useful for complete groups, fully filled containers, completed units, lower range boundaries, and equal-width numeric buckets.
What does FLOOR(NULL) return? It normally returns NULL. Missing data should become zero only under an explicit domain rule.
Why can FLOOR in a WHERE clause affect performance? A function around an indexed column may prevent a normal index seek; an equivalent range can sometimes be more efficient.
Key Takeaway
FLOOR returns the integer boundary toward negative infinity. It is reliable when SQL needs a mathematical lower boundary, the number of complete groups, or the start of an equal-width bucket.
RELIABLE FLOOR CALCULATION = CORRECT MATHEMATICAL DIRECTION
+ FRACTION-PRESERVING ARITHMETIC
+ VALID DIVISORS AND COMPATIBLE UNITS
+ EXACT TYPES AT IMPORTANT BOUNDARIES
+ PERFORMANCE-AWARE PREDICATES
+ CROSS-DATABASE TESTING
Remember that FLOOR(-12.1) is -13, not -12. Use CEIL when a partial group still requires another complete resource, use ROUND for nearest-value rules, and use truncation only when movement toward zero is the documented requirement. With clear semantics, validated inputs, suitable numeric types, and boundary tests, FLOOR becomes a precise tool for production SQL rather than a shortcut for removing decimals.