Home Page for the TeradataForum
 
 

 

Archives of the TeradataForum





Message Posted: Fri, 12 Sep 2003 @ 08:30:09 GMT





     
  <Prev Next>   <<First <Prev
Next>
Last>>
 




Subj:   Re: Rounding and the ceil function
 
From:   Dieter Noeth



Burton, Bruce wrote:

  so if I want anything over the integer value to be rounded up like the SAS ceil function I would use the below (ie/ I want 2.1 to be rounded to 3, 2.0 to stay at 2, etc.)?  


  select sum(cast(mou+0.99 as integer)) as mou <---assuming 2 decimal places on the pre-cast value.  


  Can anyone see any issues with this?  



What about negative numbers?

ceil(-2.10) -> -1, but should be -2

cast(mou as int) + (case when mou mod 1 > 0 then 1 else 0 end)


and you don't have to care about decimal places ;-)


Dieter





     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
 
  Top Home Join Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky 
Last Modified: 30 Jun 2008