Home > Net >  Select subquery for duplicate
Select subquery for duplicate

Time:08-20

last_name   first_name  id_no   Race
Carlos      Pat         45      07-White
Anderson    EJ          8       03-Black or African American
Inplace     Mom         9       08-Other Race
Inplace     Teen        10      08-Other Race
Ball        Sumu        18      07-White
Ball        Sumu        18      07-White

i would only be interested Ball Sumu as it is a duplicate. there are 12000 rows

i have this code but is faulty.

select ac.last_name, ac.first_name, ac.id_no, ri.description as race from all_clients_view ac
inner join race ra
on ac.people_id = ra.people_id
inner join race_info ri
on ra.race_info_id = ri.race_info_id
where ac.people_id in (select ce.people_id from race ce)
order by id_no

CodePudding user response:

If you are looking to see which entries are duplicated, try something like:

select last_name,first_name,count(*) from all_clients_view group by last_name,first_name having count(*) > 1;
  •  Tags:  
  • sql
  • Related