TRUNC and ROUND function looks similar but not exactly.
ROUND function used to round the number to the nearest while TRUNC used to truncate/delete the number from some position. 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
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 |
So next time when you are using TRUNC and ROUND remember that both might give different results !
Difference between DECODE and CASE
Oracle Cursors
Find Nth highest salary
Polymorphism in Oracle
Install Notepad++ in Ubuntu
Oracle 12c New Features
Oracle Interview questions and answers
5 Different ways to delete records Oracle
round() gives the result acc to the rounded valuebut trunc() always gives min value
Nice explanation