Sunday, August 15, 2010

Oracle 11g: Using Number Functions ROUND and TRUNC

select 45.923 as ringgit
from dual;

Results:
RINGGIT               
----------------------
45.923 


===> SQL Queries:
select round(45.923,2),
       round(45.923,0),
       round(45.923,-1)
from dual;     

select trunc(45.923,2),
       trunc(45.923),
       trunc(45.923,-1)
from dual;

Results:
ROUND(45.923,2)     ROUND(45.923,0)        ROUND(45.923,-1)      
---------------------- ---------------------- ----------------------
45.92                  46                     50                    


TRUNC(45.923,2)     TRUNC(45.923)          TRUNC(45.923,-1)      
---------------------- ---------------------- ----------------------
45.92                  45                     40                   

No comments: