Difference between Trunc and Round functions Oracle

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

Advertisements

Author: sqlandplsql

To learn more about the Oracle, SQL, PL SQL, Performance Tuning, Database Modeling, Ubuntu, MySQL etc .Suggestions, comments, feedbacks and referrals are highly appreciated.

2 thoughts on “Difference between Trunc and Round functions Oracle”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s