DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Duplicity Check Query

  1. #1
    Join Date
    May 2003
    Location
    Madrid
    Posts
    4

    Question Duplicity Check Query

    Hi all,

    I have a query that checks duplicity in my database. It is generated by a CRM application and the result is a report that informs me what companies, or phones, or name, that I have duplicated.
    It's a little odd query, takes toooooo long, but works.
    I would like to know if anyone know if there is a faster way to retreave the count(*) and after that the columns pairs that is repeated in my tables?


    ---------------------------------------------------------


    SELECT COUNT(*)
    FROM empresas e1, empresas e2, busqueda_empresa be1, busqueda_empresa be2,
    empresa_sub_actividad esa1, empresa_sub_actividad esa2
    WHERE be1.codpais IN (SELECT op.codpais
    FROM usu_personal up, personal p,
    oficinas_gx_paises op
    WHERE up.numero_usr = 200
    AND up.codpersonal = p.codpersonal
    AND p.codigo_oficina = op.codigo_oficina
    AND op.codidioma = 'ING')
    AND be1.codpais = be2.codpais
    AND be1.codciudad = be2.codciudad
    AND be1.codvol_ventas = be2.codvol_ventas
    AND be1.codvol_empleados = be2.codvol_empleados
    AND be1.codempresa > be2.codempresa
    AND e1.codempresa = be1.codempresa
    AND e2.codempresa = be2.codempresa
    AND e1.codempresa > e2.codempresa
    AND e1.telefono = e2.telefono
    AND e1.codpostal = e2.codpostal
    AND UPPER(e1.nombre_comercial) = UPPER(e2.nombre_comercial)
    AND UPPER(e1.nombre_registrado) = UPPER(e2.nombre_registrado)
    AND e1.numregistro_fiscal = e2.numregistro_fiscal
    AND e1.url = e2.url
    AND e1.dirgeneral = e2.dirgeneral
    AND e1.dirfinanciero = e2.dirfinanciero
    AND e1.codtipoempresa = e2.codtipoempresa
    AND esa1.codempresa = e1.codempresa
    AND esa2.codempresa = e2.codempresa
    AND esa1.codactividad_primaria = esa2.codactividad_primaria
    AND esa1.codempresa > esa2.codempresa




    Thx in advance
    Last edited by Fergy9; 05-16-2003 at 07:23 AM.

  2. #2
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width