Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: corrected question please see Re: Why do these two sum SQLs give different results since they should be identical Very odd!!

Re: corrected question please see Re: Why do these two sum SQLs give different results since they should be identical Very odd!!

From: roger <roger.trollerNOroSPAM_at_trivadis.com.invalid>
Date: 2000/05/26
Message-ID: <028d09ac.3217f037@usw-ex0109-069.remarq.com>#1/1

The problem are possible NULL values in those two columns.

The result of the first Statement should be higher (if the figures are positive) as the sum on the column values is build independently from the value of the other column. Whenever one of the columns has a NULL value in Statement 2 the value of the other statement will be ignored as the result of a calculation "figure + null" is also null.

You should take care on null values in both statements!

Statement 1:

SELECT ( NVL(SUM(...),0) + NVL(SUM(...),0) ) / 2 ..

Statement 2:

SELECT ( SUM(NVL(...,0)) + SUM(NVL(...,0)) ) / 2 bye

Roger

Received on Fri May 26 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US