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 -> corrected question please see Re: Why do these two sum SQLs give different results since they should be identical Very odd!!

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

From: dsad <adads_at_asdad.com>
Date: 2000/05/25
Message-ID: <9MjX4.16203$if.103806@newscene.newscene.com>#1/1

it should be

 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

is not same as

 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

SUM(NBR_KW_PER_INTERVAL_1)+ SUM(NBR_KW_PER_INTERVAL_2))/2 In article <8gkdhk$30b$1_at_nnrp1.deja.com>, kal121_at_my-deja.com wrote:
>I imagine your first query has a much bigger result! These queries are
>definitely NOT the same. In the first query, you are adding the SUM of
>INTERVAL_2 to INTERVAL_1 for every single INTERVAL_1 row. In the second
>query, you are simply adding INTERVAL_1 to INTERVAL_2 together then
>doing a sum/2.
>
>This is not identical:
>SUM((NBR_KW_PER_INTERVAL_1)+ SUM(NBR_KW_PER_INTERVAL_2))/2
>
>This is:
>(SUM(NBR_KW_PER_INTERVAL_1)+ SUM(NBR_KW_PER_INTERVAL_2))/2
>
>Your parenthesis is in the wrong place.
>
>
>In article <7VgX4.15674$Ms1.428271_at_zombie.newscene.com>,
> 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
>>
>>
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
Received on Thu May 25 2000 - 00:00:00 CDT

Original text of this message

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