1
I have three tables, which are the following : ALUNO
,CLASSE
and MATRICULA
.
PUPIL
NR_RGM
NM_NOME
NM_PAI
NM_MAE
DT_NASCIMENTO
ID_SEXO
CLASS
CD_CLASSE
NR_ANOLETIVO
CD_ESCOLA
CD_GRAU
NR_SERIE
TURMA
CD_PERIODO
LICENSE PLATE
CD_CLASSE
NR_RGM
DT_MATRICULA
I’m making a INNER JOIN
with the three tables to return me a query. This is the query :
select a.nm_nome
from aluno a
inner join matricula ma on (ma.nr_rgm = a.nr_rgm)
inner join classe c on (c.cd_classe = ma.cd_classe)
where a.nm_nome LIKE '%SILAS%' AND c.cd_classe = ma.cd_classe
The query works, but the problem is that it returns me repeated results. And appears in Oracle by the following results :
How can I do just returns me the required data without being repeated ? I know there are already some other similar questions, but they didn’t help me in what I need.
If you only want to bring 1 record of each, make a grouping by PK, example
group by a.nr_rgm
, the reason to bring several lines is that some table has more than 1 record referring to the student/matricula– Don't Panic
Yes I managed to solve here now through GROUP BY in which I used the name instead of the primary key and it worked out, thank you very much. If you want, you can put as an answer and I’ll give you the right answer.
– Monteiro