# Thread: how to make the calculation process more efficient ?

1. Registered User
Join Date
Nov 2009
Posts
17

## Unanswered: how to make the calculation process more efficient ?

i have query like this :

select groupid, sum(A) as V1, sum(b), as v2, (sum(A) * sum(C) ) as v3, (sum(A) * sum(B)) as v4 from Table1
group by groupid order by groupid

my question is :
1. is sum calculation process doing more than once ?? (like sum(A))
2. how to make this query more efficeint ?? for doing sum calculation ?

thank's
Jigu
Last edited by jigujigu2; 12-22-09 at 14:44. Reason: Query is edited

2. Annie's Dog Walker
Join Date
Nov 2004
Location
on the wrong server
Posts
8,842
Originally Posted by jigujigu2
my question is :
1. is sum calculation process doing more than once ?? (like sum(A))
2. how to make this query more efficeint ?? for doing sum calculation ?
can't fix it if we can not see it. see Pats instructions in the sticky at the top of the forum.

3. Registered User
Join Date
Jun 2008
Location
Chennai
Posts
21
i don't say the following code is efficient, but assume it will reduce some execution time

Select groupid, tmp.A as V1, tmp.B as V2, (tmp.A * tmp.C) as V3, (tmp.A * tmp.B) as V4
From
(select groupid, sum(A) as A, sum(B) as B, sum(C) as C
From table1
group by groupid
order by groupid) as tmp

4. Registered User
Join Date
Nov 2009
Posts
17
Originally Posted by kandrusatish
i don't say the following code is efficient, but assume it will reduce some execution time

Select groupid, tmp.A as V1, tmp.B as V2, (tmp.A * tmp.C) as V3, (tmp.A * tmp.B) as V4
From
(select groupid, sum(A) as A, sum(B) as B, sum(C) as C
From table1
group by groupid
order by groupid) as tmp
it's clear now.

Thank's
Jigu

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•