0

I'm trying to make this query but it's returning too much rows

SELECT 
Denuncia.codigoAsociado,    
Involucrado.nombreCompleto 
FROM 
Denuncia 
RIGHT JOIN 
Involucrado ON Denuncia.ID = Involucrado.idDenuncia

I would like to get one codigoAsociado and one nombreCompleto. I have tried using DISTINCT but it's the same.

This is the result (check the link) Sorry can't post images

http://oi62.tinypic.com/2l9gwnp.jpg

I need it to look like this

codigoAsociado | nombreCompleto

341130402 | Juan Carlos Espinoza López

341131290 | Carlos Queirolo Rochabrun

.

.

.

341131600 | Enrique Froemel

341131949 | Raúl Muñoz

Thanks in advance

1 Answers1

0

I use Oracle DB but in Access should work this:

SELECT 
TOP 1 Denuncia.codigoAsociado,    
Involucrado.nombreCompleto 
FROM 
Denuncia 
RIGHT JOIN 
Involucrado ON Denuncia.ID = Involucrado.idDenuncia

The TOP number tell you how many rows will be returned. You should also use TOP 10 PERCENT and it returns first 10% of records.

If you need only unique records, try to use this code

SELECT 
DISTINCT Denuncia.codigoAsociado,    
Involucrado.nombreCompleto 
FROM 
Denuncia 
RIGHT JOIN 
Involucrado ON Denuncia.ID = Involucrado.idDenuncia

DISTINCT in Access has been also discussed in this post how to use distinct in ms access.

Community
  • 1
  • 1
astrak
  • 205
  • 1
  • 3
  • 9