ceil function in oracle!

Database

ceil function in oracle!

Any function in teradata is equal to the "ceil" function in oracle?

*Reference:
In Oracle/PLSQL, the ceil function returns the smallest integer value that is greater than or equal to a number.

The syntax for the ceil function is:

ceil( number )

number is the value used to find the smallest integer value.

For example:

ceil(32.65) would return 33.
ceil(32) would return 32.
ceil(-32.65) would return -32.
ceil(-32) would return -32.
3 REPLIES

Re: ceil function in oracle!

There is no ceil function in teradata but the results can be achieved easily by the below query:

select CASE
WHEN NUM > 0 THEN
CAST(NUM AS INTEGER) +1
WHEN NUM < 0 THEN
CAST(NUM AS INTEGER)

ELSE
CAST(NUM AS INTEGER)
END ceil_function, NUM
FROM ceil_function;

ceil_function NUM
25 24.999
-11 -11.230
-17 -17.231
2 1.230

Re: ceil function in oracle!

That is close, but it adds 1 to numbers that are already integers. If you pass in 2, you should get 2 back. I changed it so it checks to see if NUM is already the equivalent of it's integer value, and it returns NUM for that case.

select CASE WHEN NUM = CAST( NUM as integer) THEN NUM
WHEN NUM > 0 THEN CAST(NUM AS INTEGER) +1
WHEN NUM < 0 THEN CAST(NUM AS INTEGER)
ELSE CAST(NUM AS INTEGER)END

Re: ceil function in oracle!

Teradata 13 says new mathematical function like ceiling and floor has been added.. any examples on that