Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 16 May 2014 @ 13:02:31 GMT


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


Subj:   Re: Rounding off decimals to nearest integer
 
From:   Dave Wellman

Hi,

Yes, ROUND is implemented as a udf and is standard on TD 14.0 + systems.

If you haven't got that or do not use it (for whatever reason) then you're looking at the two 'older' ways of rounding in Teradata.

1) In DBSControl there is a setting called RoundHalfWayMagUp, defaults to FALSE. If set to TRUE then rounding follows what is often known as 'bankers rounding'. This should achieve what you want. However, that applies system-wide.

2) At the individual SQL request level do it the 'really old' way:

     SELECT CAST((15.37 + .5) AS INTEGER) AS d1, CAST((15.67 + .5) AS INTEGER) AS d2;

This example rounds the first to 15 and the second to 16. I think that is what you want.


Cheers,

Dave

Ward Analytics Ltd - Information in motion (www.ward-analytics.com)



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023