SQL FLOOR
The mirror of CEIL — always rounds DOWN to the nearest whole number, regardless of how large the decimal remainder is.
What & Why
FLOOR(n) always rounds down to the previous whole number. Common use: computing "how many complete units fit" — 4583.99 months of runway means only 4583 complete months have actually passed.
See How It Works
BUSINESS QUESTION
Product wants completed full rating points after a calculated adjustment.
| id | user_id | feature_id | rating | nps_score | comment | created_at |
|---|---|---|---|---|---|---|
| 1 | 101 | 1 | 5 | 9 | Clear and useful | 2024-01-25 12:15:00+00 |
| 2 | 102 | 2 | 4 | NULL | Export worked well | 2024-02-20 15:40:00+00 |
| 3 | 103 | 1 | 4 | 7 | Helpful setup flow | 2024-03-18 09:05:00+00 |
| 4 | 104 | 3 | 3 | NULL | Needs clearer timing | 2024-04-08 17:30:00+00 |
EXAMPLE QUERY
SELECT
id AS feedback_id,
rating,
FLOOR(rating * 0.9) AS adjusted_full_points
FROM product.feedback
ORDER BY feedback_id;RESULT — exact output from the displayed Queryflo rows
| feedback_id | rating | adjusted_full_points |
|---|---|---|
| 1 | 5 | 4 |
| 2 | 4 | 3 |
| 3 | 4 | 3 |
| 4 | 3 | 2 |
FLOOR keeps only completed whole points after the 0.9 adjustment.
Now You Try
Practice this concept
Product wants completed full rating points after a calculated adjustment.
Available schema
productPrefix tables with product.table_name.
feedback_idratingadjusted_full_pointsproduct.feedback| Column | Type |
|---|---|
| id | integer |
| user_id | integer |
| feature_id | integer |
| rating | integer |
| nps_score | integer |
| comment | text |
| created_at | timestamp with time zone |
| moderation_bucket | text |
query.sql
Sign up free to try it on a real business scenario