Results 1 to 4 of 4
  1. #1
    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. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Quote Originally Posted by jigujigu2 View Post
    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.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    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. #4
    Join Date
    Nov 2009
    Posts
    17
    Quote Originally Posted by kandrusatish View Post
    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
  •