SQL Language (MOSC)

MOSC Banner

query with wrong calculation

in SQL Language (MOSC) 10 commentsAnswered

Hello,

We have a problem in the result of table field values, I want to understand if there is a bug or some incompatibility.

this is not a performance issue.


--Original Table field values

select cred_deb,sum(VALOR) valor from luizpereira.debug_resumo group by cred_deb;

CRED_DEB valor

D 1467607,75

C 44228259,28


--Query original - not work

select sum(case when CRED_DEB = 'D' then VALOR*-1 else 0 end) valor from luizpereira.debug_resumo;

result:

Valor

0


--Query teste (without multiply by -1) -- works

select sum(case when CRED_DEB = 'D' then VALOR else 0 end) valor from luizpereira.debug_resumo;

Tagged:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center