Question
Assume that we have the following data.
How can we join table1 and table2 with Date and Product_code fields as Full Outer join, and link master to the result such as follows?
Assume that we have the following data.
How can we join table1 and table2 with Date and Product_code fields as Full Outer join, and link master to the result such as follows?
IF ISNULL([Product code]) THEN [Product code (table2)] ELSE [Product code] END6. Configure the Join setting as follows.
SELECT [table1].[Date] AS [Date], [table1].[Product_code] AS [Product_code], [table1].[Sales] AS [Sales], [table2].[Date] AS [Date (table2)], [table2].[Product_code] AS [Product_code (table2)], [table2].[Profit] AS [Profit], [master].[Product_code] AS [Product_code (master)], [master].[Product_name] AS [Product_name] FROM [dbo].[table1] [table1] FULL JOIN [dbo].[table2] [table2] ON [table1].[Date] = [table2].[Date] AND [table1].[Product_code] = [table2].[Product_code] LEFT JOIN [dbo].[master] [master] ON [table1].[Product_code] = [master].[Product_code] OR [table2].[Product_code] = [master].[Product_code]