Results 1 to 2 of 2

Thread: Query Help

  1. #1
    Join Date
    Apr 2013
    Posts
    1

    Unanswered: Query Help

    I have this part in my select statement

    sum(t.orig_price * t.qty) - (sum(t.orig_price * t.qty)- te.amt) as AMT

    this works fine line by line. But when i want to tadd the values together i tried below..

    sum ( (t.orig_price * t.qty) - ( (t.orig_price * t.qty)- te.amt) as AMT

    it somewhat doubles the value.

    Could you help?

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    sum(t.orig_price * t.qty) - (sum(t.orig_price * t.qty)- te.amt) as AMT
    Let X = sum(t.orig_price * t.qty),
    then the expression is
    X - (X - te.amt) as AMT
    It is euivalent to
    te.amt as AMT

    sum ( (t.orig_price * t.qty) - ( (t.orig_price * t.qty)- te.amt) as AMT
    Parentheses are not matched.
    (4 left parenthesis vs. 3 right parenthesis)

Posting Permissions

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