Problems With INNER JOIN PUT A CASE WHEN when you are a CONCAT

-2

I can not round off, what I need is that I have a left join of which the ON is two concat

LEFT JOIN BD_MigracionQV.dbo.TBL_QV_Hecho_Produccion_IF Produccion 
  ON CONCAT(Cita.IdPaciente, Cita.IdMedico,
 convert(char(10), Cita.FechaCita,101))=CONCAT(Produccion.IdPaciente,Produccion.IdMedicoAtencion,convert(char(10),Produccion.Fecha,101)) 

What happens is that in this part you join the two tables that one is good but the problem is the date that changes In the first CONCAT is fine but in the second varies on the date as commented, The concat can be one like this

CONCAT(Produccion.IdPaciente,Produccion.IdMedicoAtencion,convert(char(10),
Produccion.Fecha,101)) o CONCAT(Produccion.IdPaciente,Produccion.IdMedicoAtencion,
convert(char(10),Produccion.FechaInicioOa,101)) 
    
asked by Christian Guerra Huertas 24.09.2018 в 17:46
source

1 answer

0

Unfortunately, I do not fully understand the question and I really think that more information or lack of information is needed to apply your solution in a different way.

Why do you need such a complex union between two tables using concatenations? Maybe what you're looking for is done more by a where than by the union itself.

You can join the columns separately as follows:

left join tabla2 tbl2 on tbl1.idMedico=tbl2.idMedico and tbl1.idPaciente=tbl2.idPaciente
    
answered by 24.09.2018 / 17:54
source