I have 3 tables Product, DailyProduct and Location
Table product is master table contains column [ProductId, Name, Code, LocationId]
table DailyProduct contains column [DailyProductId, ProductName, ProductCode,
CreatedOn] and Table Location contains column [LocationId, LocationCode, LocationName]
I have to show data of dbo.DailyProduct Behalf of case bases
If DailyProduct.Created> '2018-01-01' Then apply join with ProductName else join with ProductCode.
Its not working Thanks in advance
What I have tried:
select DP.ProductName, DP.ProductCode FROM [dbo].[DailyProduct] DP
CASE WHEN DP.CreatedOn <= '2018-01-01' THEN
LEFT JOIN Product P ON DP.ProductName = P.Name
ELSE LEFT JOIN ProductP ON DP.ProductCode = P.Code