Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Why do these two sum SQLs give different results since they should be identical Very odd!!
On 25 May 2000 16:28:19 -0500, julio234_at_hotmail.com (Julio) wrote:
>SELECT (
>SUM((NBR_KW_PER_INTERVAL_1)+ SUM(NBR_KW_PER_INTERVAL_2))/2
>FROM
>tf_interval_meter_usage a, td_billing_acct b, td_service_point c, td_meter d
>
>
>SELECT
>sum(NBR_KW_PER_INTERVAL_1 + NBR_KW_PER_INTERVAL_2 )/2
>FROM
>tf_interval_meter_usage a, td_billing_acct b, td_service_point c, td_meter d
>
The problem is that some of the records have NULLs in one of the two fields. These rows will not participate in the second SELECT thus rendering smaller result. To prove the point run this:
SELECT count(NBR_KW_PER_INTERVAL_1), count(NBR_KW_PER_INTERVAL_2),
count(NBR_KW_PER_INTERVAL_1 + NBR_KW_PER_INTERVAL_2 ) FROM ..........<whatever>
You'll see that the third count will be less then either of the first two. Received on Fri May 26 2000 - 00:00:00 CDT
![]() |
![]() |