TRUNC and ROUND function looks similar but not exactly.
ROUND function used to round the number to the nearest but TRUNC used to truncate/delete the number from some position.
Syntax:
TRUNC(number, precision);
ROUND(number, precision);
Some cases both returns same result.
SQL> select trunc(25.67),round(25.67) from dual;
Below chart clearly explains the difference
ROUND function used to round the number to the nearest but TRUNC used to truncate/delete the number from some position.
Syntax:
TRUNC(number, precision);
ROUND(number, precision);
Some cases both returns same result.
SQL> select trunc(25.67),round(25.67) from dual;
| TRUNC(25.67) | ROUND(25.67) | 
|---|---|
| 25 | 26 | 
Below chart clearly explains the difference
| Input | TRUNC | ROUND | 
|---|---|---|
| 25.67,0 | 25 | 26 | 
| 25.67,1 | 25.6 | 25.7 | 
| 25.34,1 | 25.3 | 25.3 | 
| 25.34,2 | 25.34 | 25.34 | 
| 25.67,-1 | 20 | 30 | 
No comments:
Post a Comment