I'm working with 2 queries and would like a way to put the 2 in one, but I'm having trouble.
I have the following example:
Table T1:
CD PF Data Total
1 JSL001 15/03/2018 100
Table T2:
ID PF Data Motivo Total
45 JSL001 15/03/2018 X 85
46 JSL001 15/03/2018 Y 15
I need to mount a query in which I have the values of T1 complemented by the values of T2 using the comparative field of Date and PF,
In this way the expected result would be as follows:
CD PF Data Total T2.Motivo T2.Total
1 JSL001 15/03/2018 100 X 85
1 JSL001 15/03/2018 100 Y 15
I tried with Subqueryes, but when it returns more than one line it does not accept, I also could not implement a UNION for that.
I'm using SQL Server 2014