1
Hi, I need a hand, if you can help me, I appreciate.
I need to query between three tables, however, when I search the query is returning me duplicate lines:
SELECT US.NOME AS PROFISSIONAL, AG.NOMEPACIENTE AS NOME_PACIENTE, CONV.NOME
AS CONVENIO, AG.NUMEROPRONTUARIO, AG.DATA,
P.CODIGOAMB AS DESCRICAO_ATENDIMENTO, P.TOTALTAXAS AS TOTAL_TAXAS,
P.TOTALDIARIAS AS TOTAL_DIARIA
FROM T_AGENDACONSULTAS AS AG
JOIN T_USUARIOS AS US ON AG.USUARIO = US.CODIGO
JOIN T_CONVENIOS AS CONV ON AG.CONVENIO = CONV.CODIGO
JOIN T_PACIENTESCONTAS AS P ON AG.NUMEROPRONTUARIO = P.PACIENTE
WHERE DATA BETWEEN '2019/06/01' AND '2019/06/30' AND NOMEPACIENTE='augusto prazeres'
Try putting Select Distinct after your fields
– Danielle Arruda torres
If the answer served, mark it as right
– Danielle Arruda torres