Duplicate records in SQL query

1

Holas I have the following query in SQL Server:

SELECT P.ProyId, P.ProyCodigoSNIP, P.Proyecto, E.EtapaAbr
FROM PROYECTO AS P, PROYECTO_ETAPA AS PE, ETAPAS AS E
WHERE P.ProyId=PE.ProyId AND PE.ProyEtapa=E.EtapaId

As you can see, I consult 3 tables, but the results are duplicated:

Could you please support me in what I should include or modify my query so that they do not appreciate the duplicate records. Thanks in advance.

    
asked by Alcibiades Palestini 27.06.2018 в 07:22
source

1 answer

0

Using the clause DISTINCT , the following way should suffice to filter the records in a unique way

SELECT DISTINCT P.ProyId, P.ProyCodigoSNIP, P.Proyecto, E.EtapaAbr
FROM PROYECTO AS P, PROYECTO_ETAPA AS PE, ETAPAS AS E
WHERE P.ProyId=PE.ProyId AND PE.ProyEtapa=E.EtapaId;
  

Within the statement this attribute helps to differentiate the values   that are duplicates and take only one of them, with which your   List of records should only have unique records

    
answered by 27.06.2018 в 07:25