Skip to content

FLOOR

Round a number down to the next whole number (a positive or negative integer).

FLOOR(number)

For example:

premdb=# SELECT FLOOR(2.5);
 ceil 
------
   2
(1 row)
premdb=# SELECT FLOOR(-1.2567);
 ceil 
------
   -2
(1 row)

The following example finds the "floor" for the results of an AVG function.

premdb=# SELECT seasonid, AVG(SUBSTR(ftscore,3,1)::INT), 
FLOOR(AVG(SUBSTR(ftscore,3,1)::INT)) floorgoals FROM match GROUP BY seasonid ORDER BY 2;
 seasonid |            avg            | floorgoals 
----------+---------------------------+------------
      15 | 0.99736842105263157894736 |          0
      14 | 1.02368421052631578947368 |          1
      13 | 1.06578947368421052631578 |          1
       9 | 1.06578947368421052631578 |          1
       7 | 1.06842105263157894736842 |          1
...

Parent topic:Mathematical Functions