Rounding CALCULATION

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Post Reply
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

Hello everyone, good morning,

I am doing a calculation and I have a doubt for example:

I have the following table:

Select all

P.VLTITULO / 1.3496 * 1.0889
] Then he brings a bitch result ai tried to round him to get the decimal houses também but he rounded down I need to do so:

that he does the calculation and round up bringing the Two decimal houses I tried like this but he brought down ex: 112,076985032602 ai I used this option with the truncular

Select all

TRUNC (P.VLTITULO / 1.3496 * 1.0889)
calculation and he brought (112)

I need to take the two decimal places After 112

would be more or less like this 112,07
Tineks
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 365
Joined: Tue, 24 May 2005 2:24 pm
Location: Araraquara - SP
Cristiano (Tineks)
Araraquara - SP

And ai carlos, beleza ??

Dude, try to use the Round informed that you want to round up in the second decimal house .. Here is an example ..

Select all

 
SQL> SELECT ROUND(1.523,2) FROM DUAL 
  2  / 
 
ROUND(1.523,2) 
-------------- 
          1.52 
 
SQL> SELECT ROUND(1.524,2) FROM DUAL 
  2  / 
 
ROUND(1.524,2) 
-------------- 
          1.52 
 
SQL> SELECT ROUND(1.525,2) FROM DUAL 
  2  / 
 
ROUND(1.525,2) 
-------------- 
          1.53 
 
SQL> SELECT ROUND(1.526,2) FROM DUAL 
  2  / 
 
ROUND(1.526,2) 
-------------- 
          1.53 
's
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

Hello my friend once again giving me a force,


face how do I do this? I can put it like this:

Round (p.vltitulo - And what do I get now?
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

I still have the calculation inside to be done not knowing

Round (p.vltitulo / 1,3496 * 1,0889) It brings rounded







:(
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

Rounding has to be done after the calculation
Tineks
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 365
Joined: Tue, 24 May 2005 2:24 pm
Location: Araraquara - SP
Cristiano (Tineks)
Araraquara - SP

The Round accepts 2 parameters, the first is the value you want to round, the second is the number of decimal places you want ..
For example ..

Select all

 
   v_RESULTADO := ROUND(v_TOTAL,2); 
99]] or

Select all

 
   v_RESULTADO := ROUND( P.VLTITULO / 10  ,2); 

or

Select all

 
   v_RESULTADO := ROUND( (P.VLTITULO / 10)*0.10  ,2); 
's !!
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

Pow dude now gave right my friend brigado once again
Cristiano (tineks)


MORE I'm opening another topic for your knowledge See if it's easy too For I have this doubt for days

a strong embrace
Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 13 guests