Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Displaying data in specific format

671966Feb 23 2010 — edited Feb 27 2010
Hi i have 2 tables without relation and only relation is branch and i want to display 2 tables data in the following format
I tried the following query but its not giving the desired result like below.



create table gl_br
(br varchar2(10),
ref_no varchar2(20),
curr varchar2(10),
amt number(15,4),
trdt date)


create table trn_br
(Tn_br varchar2(10),
Tref_no varchar2(20),
Tcurr varchar2(10),
Tamt number(15,4),
trndt date)




br--- ref_no----- curr--- amt----trdt ----- Tn_br-----Tref_no-------Tcurr ------Tamt---- trndt
01---12332-----IRS---10230---01-FEB-10-01-----14355------IRS-----------4000-02-FEB-10
-------------------------------------------------------- 01-----34234-----IRS------------10000--03-FEB-10
----------------------------------------------------------01------5342-------USD------------20000-02-FEB-10
02-12455----IRS-------1000---03-FEB-10----02-------45345-----IRS------------50000-------30-JAN-2010
02----15666-USD---------4000-30-JAN-10---02---56345---USD--------4000-----------31-JAN-2010
02-45666----IRS---------1000-31-JAN-10----02--5783434-IRS-----10000----------04-FEB-2010
02-674545-IRS-----------20000-10-FEB-10------------------------------------------------------------------
02-4234342-IRS----30000--------10-FEB-10----------------------------------------------------------------

select trdt,ref_no,br,curr,amt,trdt,tn_br,tref_no,tcurr,tamt
from
(select r.trdt,r.ref_no,r.br,r.curr,r.amt,b.trDt,b.tref_no,b.tn_br,b.tcurr,b.tamt
from ( select trdt,ref_no,br,curr,am, row_number() over(partition by br, order by ref_no) as gbr from gl_br)r full outer join
(select tr_dt,tn_br,tref_no,tcurr,tamt,row_number() over (Partition by tn_br order by tref_no)as fbr from trn_br )b
on(r.br =b.tn_br)
and (r.gbr=b.fbr))


rgds
shrey
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2010
Added on Feb 23 2010
18 comments
1,855 views