Results 1 to 2 of 2

Thread: qry

  1. #1
    Join Date
    Sep 2002
    Posts
    17

    Unanswered: qry

    SELECT FUNDNBR, TRANSTYPE,SUM(DOLLARAMOUNT)
    2 FROM FO_TRADING_T
    3 GROUP BY FUNDNBR, TRANSTYPE

    FUNDNBR TRA SUM(DOLLARAMOUNT)
    -------- --- -----------------
    1003 I 10000000
    1004 I 60000000
    1004 R 15000000


    how to get the difference between the dollaramount of I and R thatis
    for 1004 I value and R value are 60000000-15000000=45000000
    where as for 1003 there isno R status so value should be 10000000-0=10000000
    how can we write a qryfor this

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: qry

    Outer join the table to itself:

    SELECT i.fundnbr, i.dollaramount - NVL(r.dollaramount,0) diff
    FROM fo_trading_t i
    , fo_trading_t r
    WHERE i.fundnbr = r.fundnbr (+);

Posting Permissions

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