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!!
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