Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 16 May 2002 @ 16:43:36 GMT


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


Subj:   Re: Rounding in Teradata
 
From:   Scott Summers

I am not 100 percent sure what you are trying to do, but here's the poor man's less than elegant work around to force the rounding from hundredths to tenths to work as you want. This works for numbers > 0, but you could add logic to handle negative numbers too.

select  decimal_value, case when ((decimal_value mod .1) < .05) then
(decimal_value -   decimal_value mod .1)  else   ((decimal_value -
decimal_value mod .1 ) + .1) end Rounded_value

        decimal_value   Rounded_value
        261.01          261.00
        368.51          368.50
        15.91                   15.90
        100.19          100.20
        358.62          358.60
        43.86                   43.90
        66.22                   66.20
        163.83          163.80
        228.33          228.30
        181.03          181.00
        372.81          372.80
        72.67                   72.70
        10.75                   10.80
        36.98                   37.00
        214.57          214.60
        65.79                   65.80
        352.17          352.20
        428.71          428.70
        349.59          349.60
        43.43                   43.40


     
  <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