| René Nyffenegger's collection of things on the web | |
|
René Nyffenegger on Oracle - Most wanted - Feedback
|
SQL: ceil and floor [SQL] | ||
ceil (n) floor(n)
ceil rounds n up to the next higher integer. If n is already rounded, it returns n.
floor rounds n down to the next higher integer. If n is already rounded, it returns n.
Demonstrationcreate table ceil_floor_test ( a number ); insert into ceil_floor_test values ( 1.255); insert into ceil_floor_test values ( 197.001); insert into ceil_floor_test values ( 68.995); insert into ceil_floor_test values ( 50.500); insert into ceil_floor_test values ( -1.000); insert into ceil_floor_test values ( -10.250); select a, ceil(a) c, floor(a) f from ceil_floor_test;
A C F
---------- ---------- ----------
1.255 2 1
197.001 198 197
68.995 69 68
50.5 51 50
-1 -1 -1
-10.25 -10 -11
|