0
Good afternoon! I’m making a query, but the result is bringing repeated occurrences. there is some command for the query to only bring a record of each column?
follows script:
SELECT *
FROM HIS_LOTPES A, his_afasta c, FERIAS D, PESSOAL P
WHERE A.HLOT_PESS_CD_MAT = c.hafa_pess_cd_mat(+)
AND A.HLOT_PESS_CD_MAT = D.FERI_PESS_CD_MAT(+)
AND P.PESS_CD_MAT = D.FERI_PESS_CD_MAT(+)
and a.hlot_dt_inicio <> c.hafa_dt_inicial(+)
and a.hlot_dt_saida <> c.hafa_dt_final(+)
and a.hlot_dt_inicio < feri_dt_inicio(+)
and a.hlot_uorg_cd_ent = '2'
and a.hlot_uorg_ufed_sg = 'DF'
and a.hlot_uorg_cd_org = '1'
and a.hlot_uorg_cd_gab = '101'
and a.hlot_uorg_cd_dep = '2'
and a.hlot_uorg_cd_div = '0'
and a.hlot_uorg_cd_set = '1'
and a.hlot_uorg_cd_sec = '1'
AND A.HLOT_DT_INICIO > '01/01/2015'
Thank you!
Have you tried using the
distinct
? Select distinct * from HIS_LOTPES...– Eduardo Mendes
I think I’ve seen an identical question these days, I get the impression this is a duplicate. The problem was exactly a Join with an N:N ratio, probably the same as what happens here. Incidentally, implicit joins mounted with WHERE usually get harder to read, analyze and adjust, I would suggest making explicit, choosing the right junction types according to the desired result.
– Bacco