Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Posts
    8

    Unanswered: please help me with this

    Somebody that has knowledge of ORACLE, could say if a similar function exists to the DECODE, to make something similar to the following thing in DB2:

    select a_cuenta,
    sum(decode(codigo, ' D',importe,0) as debitos,
    sum(decode(codigo, ' C',importe,0) as creditos
    from movements
    group by a_cuenta

    thank you for your help

    Sincerely

    Rubén Troche

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: please help me with this

    I think it is

    select a_cuenta,
    sum(case
    when codigo='D' then importe
    else 0
    end
    ) as debitors,
    sum(case
    when codigo='C' then importe
    else 0
    end
    ) as creditors
    from movements
    group by a_cuenta

    Hope this helps

    Cheers

    Sathyaram

    Originally posted by cytrus
    Somebody that has knowledge of ORACLE, could say if a similar function exists to the DECODE, to make something similar to the following thing in DB2:

    select a_cuenta,
    sum(decode(codigo, ' D',importe,0) as debitos,
    sum(decode(codigo, ' C',importe,0) as creditos
    from movements
    group by a_cuenta

    thank you for your help

    Sincerely

    Rubén Troche

Posting Permissions

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