To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
TABLE1
FirstnameSurname DOB File no
A Smith 1/04/1980 122
A Smith 1/04/1980 200
B Adam 2/04/1988 110
C Smith 12/04/1985 250
D Miles 12/12/1945 300
D Miles 12/12/1945 400
TABLE2
File no Order date Delivery date
122 14/10/1950 14/10/1950
200 25/01/1960 2/11/1990
110 25/04/1999 25/04/1999
250 25/01/1980 11/11/1991
300 22/01/1978 23/04/1987
400 14/07/1974 25/01/1982
I want to get the cases where we have same surname,first name& DOB but only one of such file has the same order date & delivery date. So the results should look something like:
File A FileB
122 200
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Pls try this one ...this will give the correct result vertically.if you use pl\sql you will get the exact result.
select tab2.fileno
from ( select * from table2 where orddate=del_date ) tab1 right outer join
( select fileno
from table1
where firstname in ( select firstname
from table1
group by firstname,surname,dob
having count(fileno)>1)
) tab2 on (tab1.fileno=tab2.fileno)
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
select dt1.fileno from dt1,
(select firstname,surname,dob
from table1 a
where a.fileno in (select b.file_no from table2 b where b.delivery_date = b.order_date)
group by firstname,surname,dob
having count(fileno)>1) dt2
where dt1.firstname = dt2.firstname
and dt1.surname=dt2.surname
and dt1.dob = dt2.dob
select dt1.fileno from dt1,
(select firstname,surname,dob
from table1 a
where a.fileno in (select b.file_no from table2 b where b.delivery_date = b.order_date)
group by firstname,surname,dob
having count(fileno)>1) dt2
where dt1.firstname = dt2.firstname
and dt1.surname=dt2.surname
and dt1.dob = dt2.dob
Please substitute your columns in the query
===============================
select tab2.File_no
from ( select * from table2 where Order_date=Delivery_date) tab1 right outer join
( select File_no
from table1
where Firstname in ( select Firstname
from table1
group by Firstname,Surname,dob
having count(File_no)>1)
) tab2 on (tab1.File_no=tab2.File_no)