Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Can someone simplify this query
I realised that after posting. Please use this one.
select * from
(select a.officecode off1, a.acno_code acc1,
sum(current_purchase_amount) over (partition by a.office_code, a.acno_code) as sum1, rank () over (partition by a.office_code, a.acno_code) rno,
b.officecode off2, b.account_code acc2, sum(org_budget_amt) over (partition by b.account_code, b.office_code) as sum3, sum(rev_budget_amt) over (partition by b.account_code,b.office_code) as sum4 , rank() over (partition by b.account_code, b.office_code) rowno
This is the same one as before with a change that I am getting a rank for each row in the inner query and using that to pick only one row in the outer one. Received on Thu Feb 10 2005 - 01:22:29 CST