Return of duplicate SQL results [closed]

-3

I have the following SQL

SELECT 
    'inte'.'int_nome', 
    'age'.*, 
    'con_at'.'con_nome' as consultora_que_atendeu, 
    'con_ag'.'con_nome' as consultora_que_agendou 
FROM ('agendamentos' as age) 
    JOIN 'interessados' as inte ON 'inte'.'int_cod'='age'.'age_cod_interessado' 
    JOIN 'consultoras' as con_at ON 'con_at'.'con_cod'='age'.'age_cod_consultora_atendido' 
    JOIN 'consultoras' as con_ag ON 'con_ag'.'con_cod'='age'.'age_cod_consultora_agendado' 
WHERE 'inte'.'int_nome' LIKE '%baill%' 
GROUP BY 'age'.'age_cod'

However, at the time of listing, it fetches all records and prints wrong .

Even though I run the query suggested by our friend Victor:

SELECT DISTINCT
    'inte'.'int_nome', 
    'age'.*, 
    'con_at'.'con_nome' as consultora_que_atendeu, 
    'con_ag'.'con_nome' as consultora_que_agendou 
FROM ('agendamentos' as age) 
    JOIN 'interessados' as inte ON 'inte'.'int_cod'='age'.'age_cod_interessado' 
    JOIN 'consultoras' as con_at ON 'con_at'.'con_cod'='age'.'age_cod_consultora_atendido' 
    JOIN 'consultoras' as con_ag ON 'con_ag'.'con_cod'='age'.'age_cod_consultora_agendado' 
WHERE 'inte'.'int_nome' LIKE '%baill%' 
GROUP BY 'age'.'age_cod'

What am I missing in the query?

    
asked by anonymous 18.08.2016 / 16:22

1 answer

1

Just put a DISTINCT :

SELECT DISTINCT
    'inte'.'int_nome', 
    'age'.*, 
    'con_at'.'con_nome' as consultora_que_atendeu, 
    'con_ag'.'con_nome' as consultora_que_agendou 
FROM ('agendamentos' as age) 
    JOIN 'interessados' as inte ON 'inte'.'int_cod'='age'.'age_cod_interessado' 
    JOIN 'consultoras' as con_at ON 'con_at'.'con_cod'='age'.'age_cod_consultora_atendido' 
    JOIN 'consultoras' as con_ag ON 'con_ag'.'con_cod'='age'.'age_cod_consultora_agendado' 
WHERE 'inte'.'int_nome' LIKE '%baill%' 
GROUP BY 'age'.'age_cod'
    
18.08.2016 / 16:24