AVG Oracle returning very broken value

Asked

Viewed 104 times

1

Speak my darlings, I’m making an oracle average with the AVG function...

select avg (checkd) from table 

Only it sometimes returns a very broken number, for example 0.002298850574712643678160919540229885057471

how can I return a value for example 0.2 ... so on.

I appreciate any possible help !

  • from 0.002 to 0.2 would have to multiply by 100... but as said, if the problem is the number of decimals, look for the round function

  • was just an example of 0.2, I just want it to show a smaller number kk

  • only use round to round, or trunc to truncate number

  • Can you show me an example by doing a favor ? I’m new with programming

1 answer

2


You can use the functions trunc and round.

The trunc cuts the number down to x digits. The round round the number to x digits.

You can specify how many digits you want to cut/round in the second function parameter.

Example:

SELECT TRUNC(0.002298850574712643678160919540229885057471,4) truncado,
       ROUND(0.002298850574712643678160919540229885057471,4) arredondado
  FROM dual

Browser other questions tagged

You are not signed in. Login or sign up in order to post.