Results 1 to 4 of 4

Thread: decode syntax

  1. #1
    Join Date
    Aug 2005
    Location
    Kuala Lumpur, MY
    Posts
    108

    Unanswered: decode syntax

    anyone could help me here...

    Code:
    select sum(decode(status,'10',0,origin_id,'bad',0,reloads_value_j2)) sum_ppb2
    from trap_ra_ppb_balance

    is not returning the same value as

    Code:
    select sum(reloads_VALUE_j2)
    from trap_ra_ppb_balance
    where status <> '10'
    and origin_id <> 'bad'

    pls advise me whats wrong with the decode syntax.. i dont really know whether the decode syntax could do what i want...
    thanks

  2. #2
    Join Date
    Jan 2004
    Posts
    492
    Quote Originally Posted by shatishr
    anyone could help me here...
    Code:
    select sum(decode(status,'10',0,origin_id,'bad',0,reloads_value_j2)) sum_ppb2
    from trap_ra_ppb_balance
    In this code here, if the status is not 10, you are summing up the origin_id. You need something more like this with the nested decode:
    Code:
    select sum(decode(status, '10', 0, decode(origin_id, 'bad', 0, reloads_value_j2))
    Oracle OCPI (Certified Practicing Idiot)

  3. #3
    Join Date
    Aug 2005
    Location
    Kuala Lumpur, MY
    Posts
    108
    thanks alot bro..
    it really helps...

  4. #4
    Join Date
    Jan 2004
    Posts
    492
    You're welcome - glad to see it helped you out.
    Oracle OCPI (Certified Practicing Idiot)

Posting Permissions

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