Sinny
Sinny

Reputation: 167

Rounding in SQL - inconsistent results for one query?

Is there any possibility that depending on environment or other circumstances rounding result according to this SQL formula:

ROUND(2.85*23/100,2)

would return sometimes: 0.66, 0.65 or 0.6600 or is it determined to always return 0.66 ?

Upvotes: 1

Views: 35

Answers (1)

Littlefoot
Littlefoot

Reputation: 142715

SQL*Plus; set numformat affects the result. For example:

SQL> set numformat 9.99
SQL> select round(2.85*23/100, 2) from dual;

ROUND(2.85*23/100,2)
--------------------
                 .66

SQL> set numformat 9.9999
SQL> select round(2.85*23/100, 2) from dual;

ROUND(2.85*23/100,2)
--------------------
               .6600

SQL> set numformat 000G00D0
SQL> select round(2.85*23/100, 2) from dual;

ROUND(2.85*23/100,2)
--------------------
            000.00,7

SQL>

Upvotes: 2

Related Questions