All Forums Database
n4247558 3 posts Joined 07/06
01 Aug 2006
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.

vinod_sugur 22 posts Joined 04/05
02 Aug 2006

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, NUMFROM ceil_function; ceil_function NUM 25 24.999 -11 -11.230 -17 -17.231 2 1.230

Nytewynd 13 posts Joined 12/05
02 Aug 2006

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

suhel.m 3 posts Joined 04/10
30 May 2011

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

You must sign in to leave a comment.