user2855463
user2855463

Reputation: 55

Oracle Rounding down

Here my partial statement. The statement works and receive the value of 4 but instead I would prefer 3.9 in some cases the number may not be a whole number but .4,.2,.1 etc. Those numbers currently show up as "0" because Oracle rounds up. If I remove "round" I receive 3.9123458543845474586. Is there a way to display 3.9 only and .4,.2 etc. without the rounding? I know its got to be a syntax issue. When I remove round I receive an error.

round((total_qty)*((avg_qty/(sum(avg_qty)over(partition by ID)))/5),0) avg_qty

Thanks in advance.

Upvotes: 4

Views: 37121

Answers (2)

GriffeyDog
GriffeyDog

Reputation: 8386

If you always want to "round" down, the function is trunc. This should work for you:

select trunc(3.99999, 1) from dual;

Result

3.9

Upvotes: 12

Dba
Dba

Reputation: 6649

Try like this,

SELECT ROUND(3.9123458543845474586, 1) Round FROM DUAL;

     Round
----------
      3.9

For better understanding please refer this link.

Upvotes: 2

Related Questions