|
mmkrishna1919
Yak Posting Veteran
India
54 Posts |
Posted - 03/14/2013 : 10:17:50
|
Hi All,
I have two tables table 1: cno pno vno 100 10 001 100 10 002 100 10 003 200 20 001 200 21 001 200 22 001
table 2: cno amt 100 1245 200 1500
i join these two tables based on cno i will get 6 rows in result set.
but my expected result set is:
cno pno vno cno amt 100 10 001 100 1245 200 20 001 200 1500
i need reocrds with cno=01 from table2
i tried with below way,is it correct or any other best approach is there?
select * from table1 t inner join table2 t2 on t.cno=t2.cno and t.vno=(select min(t3.vno) from tabel1 t3 where t.cno=t3.cno and t.pno=t3.pno) and t.pno=(select min(t3.pno) from table1 t3 where t.cno=t3.cno and t.vno=t3.vno) Thanks..
M.MURALI kRISHNA |
|