I have a table called table1. I would like to create a table called table2 that will contain all the duplicates in table1 based on fields:same-type, ssn or id, date and code.
my atempt below doesn't work. if you have any other ideas, please let me know.
select *
insert into table2
from table1 r1
where type='f'
and type in
(Select type
from table1
where type='f'
group by type, social_security, id, date, code having count(*)>1
and ((social_security=r1.social_security) or (id=r1.id)) and
(date=r1.date) and (code=r1.code))
my atempt below doesn't work. if you have any other ideas, please let me know.
select *
insert into table2
from table1 r1
where type='f'
and type in
(Select type
from table1
where type='f'
group by type, social_security, id, date, code having count(*)>1
and ((social_security=r1.social_security) or (id=r1.id)) and
(date=r1.date) and (code=r1.code))