0
I am working with 2 consultations and would like a way to unite the 2 in one, however I am having difficulties.
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 assemble a query in which I have the values of T1 complemented by the values of T2 using as a comparative factor the field of Data and PF,
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, also I could not implement a UNION for this.
I am using SQL Server 2014
What is the relationship between the tables?
– Paulo R. F. Amorim