Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Can this query be optimized?

Can this query be optimized?

From: kirtan <kirtan.acharya_at_gmail.com>
Date: 8 Feb 2005 02:20:48 -0800
Message-ID: <1107858048.832880.168540@g14g2000cwa.googlegroups.com>


SELECT *
  FROM (SELECT officecode t1_office, account_code t1_account,

                 SUM (org_budget_amt) t1_sum_orig
            FROM bweb_budgetmaster
        GROUP BY officecode, account_code) tab1,
       (SELECT   nvl(officecode, 'a') t2_office, acno_code t2_account,
                 SUM (current_purchase_amount) t2_sum_amt
            FROM bweb_assetpurchasetxndetails
        GROUP BY officecode, acno_code) tab2
 WHERE tab1.t1_office = tab2.t2_office(+)    AND tab1.t1_account = tab2.t2_account(+)

Hi, I want to basically summarize two different tables. I want the sum of the amount grouped by office code and account code. These two fields are the same in both the tables. can i use a single group by clause and join the two tables?
The above query works fine for me, but I need to simplify these as I'm working on Crystal reports which accepts only one SELECT clause.

Thanks in advance, Received on Tue Feb 08 2005 - 04:20:48 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US