Advertisement

06.22.2007 at 03:52PM PDT, ID: 22652515
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Identify Duplicate Records with SQL

Asked by vitoto in Oracle Database

Tags: , , ,

Hi, i am have SQL Stament and need identify the duplicated records using TOAD SQL.

This is SQL :

SELECT to_char(sysdate, 'yyyymmdd') as fec, afi_asegurados.no_afiliacion,
afi_asegurados.sexo, pfd_detalle.numpat,
afi_asegurados.cod_unidad_medica || afi_asegurados.cod_clinica as centro_medico,
afi_asegurados.afi_status_asegurado, to_char(max(pfd_fechas.fechcert), 'yyyymmdd') as fecvenc, to_char(fecha_nacimiento, 'yyyymmdd') as fecha_naci,
to_char(fecha_inscripcion, 'yyyymmdd') as fecha_insc, afi_asegurados.status_registro, afi_asegurados.estado_civil,
afi_asegurados.depto_direcc || afi_asegurados.munic_direcc as depto_muni_resi, to_char(afi_asegurados.fecha_muerte, 'yyyymmdd') as fecha_muerte, RTRIM(afi_asegurados.cod_usuario) as u_systema, 'X'
FROM sgcuser.afi_asegurados, sgcuser.pat_patronos, sgcuser.pfd_detalle, sgcuser.pfd_fechas
WHERE ( (pat_patronos.no_patronal = afi_asegurados.no_patronal)
AND (afi_asegurados.no_afiliacion = pfd_detalle.numafil)
AND (pfd_detalle.periodo = pfd_fechas.periodo)
AND (to_char(pfd_fechas.fechcert, 'yyyymm') >= to_char(sysdate, 'yyyymm'))
AND (afi_asegurados.no_afiliacion <> '000000000')
AND ((afi_asegurados.afi_status_asegurado <> '5')
AND (afi_asegurados.afi_status_asegurado <> '6')
AND (afi_asegurados.afi_status_asegurado <> '13')
AND (afi_asegurados.afi_status_asegurado <> '14')
AND (afi_asegurados.afi_status_asegurado <> '15')
AND (afi_asegurados.afi_status_asegurado <> '16')
AND (afi_asegurados.afi_status_asegurado <> '17')
AND (afi_asegurados.afi_status_asegurado <> '18')
AND (afi_asegurados.afi_status_asegurado <> '7')
AND (afi_asegurados.afi_status_asegurado <> '21')
AND (afi_asegurados.afi_status_asegurado <> '22')
AND (afi_asegurados.afi_status_asegurado <> '23')
AND (afi_asegurados.afi_status_asegurado <> '24')
AND (afi_asegurados.afi_status_asegurado <> '25')
AND (afi_asegurados.afi_status_asegurado <> '31')
AND (afi_asegurados.afi_status_asegurado <> '32')
AND (afi_asegurados.afi_status_asegurado <> '33')
AND (afi_asegurados.afi_status_asegurado <> '34')
AND (afi_asegurados.afi_status_asegurado <> '35')))
Group by afi_asegurados.no_afiliacion,
afi_asegurados.sexo, pfd_detalle.numpat,
afi_asegurados.cod_unidad_medica, afi_asegurados.cod_clinica,
afi_asegurados.afi_status_asegurado, afi_asegurados.fecha_nacimiento,
afi_asegurados.fecha_inscripcion, afi_asegurados.status_registro,
afi_asegurados.estado_civil, afi_asegurados.depto_direcc, afi_asegurados.munic_direcc,
afi_asegurados.fecha_muerte, afi_asegurados.cod_usuario

KEY Values is :
afi_asegurados.no_afiliacion
pfd_detalle.numpat

Sample result :

afi_asegurados.no_afiliacion   |   pfd_detalle.numpat
000000001                               |    44555444455
000000001                               |    44555444333
000000002                               |    34343444333
000000002                               |    34343444377
000000002                               |    34343444311

I need identify the records 000000001 and 000000002

Look Result after IDENTIFY :

afi_asegurados.no_afiliacion   |   pfd_detalle.numpat      |  flag
000000001                               |    44555444455              |    x
000000001                               |    44555444333              |    
000000002                               |    34343444333              |    x
000000002                               |    34343444377              |    
000000002                               |    34343444311              |    

This Result is ok for me too :

afi_asegurados.no_afiliacion   |   pfd_detalle.numpat      |  flag
000000001                               |    44555444455              |    
000000001                               |    44555444333              |    x
000000002                               |    34343444333              |    
000000002                               |    34343444377              |    x
000000002                               |    34343444311              |    x

Any idea, thank you.



Start Free Trial
[+][-]06.22.2007 at 06:35PM PDT, ID: 19346099

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.22.2007 at 10:32PM PDT, ID: 19346612

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.24.2007 at 10:01AM PDT, ID: 19351665

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.24.2007 at 12:10PM PDT, ID: 19352111

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: duplicate, records, sql, identify
Sign Up Now!
Solution Provided By: sathyagiri
Participating Experts: 3
Solution Grade: A
 
 
[+][-]06.24.2007 at 02:10PM PDT, ID: 19352373

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.24.2007 at 05:34PM PDT, ID: 19352765

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32