DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2001
    I have a select statement that returns one value that goes something like this:

    select decode(sign(nvl(sum(a), 0), nvl(sum(b)/sum(c)),0), 1, decode(sign(nvl(sum(b),0) / nvl(sum(c),0)), -1, 5), 2)
    from table1

    now, the select above is just an example and the one im using is actually longer than that, uses 3 more decodes in that first decode.
    Now, would this be code optimization or should i do one select returning the sum value of a, b, c and then do my calculation in a series of if/else statements?

    Thanx in advance

  2. #2
    Join Date
    Sep 2001
    NJ, USA
    If u use oracle 8i and 9i u may use CASE expression.
    DECODE() and CASE .. WHEN .. on server side
    in any case faster then IF/ELSE on client side.

Posting Permissions

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

Click Here to Expand Forum to Full Width

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.