Aprenda PL/SQL

Problem with calculus

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Fri, 09 Jun 2017 5:38 pm

Knowledge holders beings on this forum I have a problem with an SQL query for a client that performs a calculation, but even if I change the value of the fields of the return is always the same, I have to humbly to your knowledge.

Follow code.

This always returns 1.04
Code: Select all
SELECT ROUND (DECODE (a.ie_sexo,'M',((TO_NUMBER('1.112','999.99999999')-(TO_NUMBER('0.00043499','999.99999999')*(TO_NUMBER(TRIM(Aval(b.nr_sequencia,3032)),'999.99999999'))) + (TO_NUMBER('0.00000055','999.99999999') * (TO_NUMBER(TRIM(Aval(b.nr_sequencia,3032)),'999.99999999') * (TO_NUMBER(TRIM(Aval(b.nr_sequencia,3032)),'999.99999999')))) - (TO_NUMBER('0.00028826','999.99999999') * (TO_NUMBER(TRIM(Aval(b.nr_sequencia,2684)),'999.99999999'))))),'F',((TO_NUMBER('1.097','999.99999999')-(TO_NUMBER('0.00046971','999.99999999')*(TO_NUMBER(TRIM(Aval(b.nr_sequencia,3032)),'999.99999999'))) + (TO_NUMBER('0.00000056','999.99999999') * (TO_NUMBER(TRIM(Aval(b.nr_sequencia,3032)),'999.99999999') * (TO_NUMBER(TRIM(Aval(b.nr_sequencia,3032)),'999.99999999')))) - (TO_NUMBER('0.00012828','999.99999999') * (TO_NUMBER(TRIM(Aval(b.nr_sequencia,2684)),'999.99999999'))))),0),2) cp
FROM atendimento_paciente_v a, med_avaliacao_paciente b
WHERE b.nr_atendimento = :nr_atendimento
AND b.nr_atendimento = a.nr_atendimento
AND b.NR_SEQ_TIPO_AVALIACAO = 227
ORDER BY b.nr_sequencia DESC
Here always returns 26
Code: Select all
SELECT ROUND(DECODE(a.ie_sexo,'M',((TO_NUMBER('4.95','999.99999999')/TO_NUMBER(TRIM(Aval(b.nr_sequencia,3036)),'999.99999999') - TO_NUMBER('4.5','999.99999999')) * 100),'F',((TO_NUMBER('4.95','999.99999999')/TO_NUMBER(TRIM(Aval(b.nr_sequencia,3036)),'999.99999999') - TO_NUMBER('4.5','999.99999999')) * 100),0),1) cp
FROM atendimento_paciente_v a, med_avaliacao_paciente b
WHERE b.nr_atendimento = :nr_atendimento
AND b.nr_atendimento = a.nr_atendimento
AND b.NR_SEQ_TIPO_AVALIACAO = 227
ORDER BY b.nr_sequencia DESC
Oracle 11.2.0.4 Bank
Dualogic

Poston Mon, 12 Jun 2017 7:39 am

Good day, what returns when you run the Eval function alone?
spernega
Location: São Paulo - SP

Poston Mon, 12 Jun 2017 8:26 am

The Eval function returns the value of a field evaluation screen that I have on my system.

the value is powered by the user based on the data collected.
Dualogic

Poston Mon, 12 Jun 2017 8:38 am

It's just a hunch, but gives the impression that it's function can be in trouble and always returns the same value to always give the same result in the select, independent of b.nr _ sequence.
spernega
Location: São Paulo - SP

Poston Mon, 12 Jun 2017 8:44 am

The problem is that this problem occurs only with this specific review, there are other reviews that the calculations are done normally.
Dualogic

Poston Mon, 12 Jun 2017 8:48 am

you provide the structure of the function and some b.nr _ query sequence?
spernega
Location: São Paulo - SP

Poston Fri, 03 Nov 2017 1:09 pm

Topic under translation. Come back later. (This is an automatic message)
DanielNN
Location: Fortaleza - CE

att,

Daniel N.N.



Return to SQL

Who is online

Users browsing this forum: No registered users and 1 guest

cron