I have this query I need to complete where I need to return the Name of the customers who brought items on a certain date and the name of each item.
However, whenever I JOIN the customer table to the other tables it essentially comes back as NULL. There is definitely data in there.
I've tried an array of different join types but none seem to link in and retain the customer info. It seems like something wrong with my join types... maybe.
Thanks in advance team!
SELECT DISTINCT PM.Name AS [ProductModel Name], P.FirstName AS [Customer Name]
FROM AdventureWorksDB.Production.TransactionHistory TH
FULL JOIN AdventureWorksDB.Production.Product PP
ON TH.ProductID = PP.ProductID
FULL JOIN AdventureWorksDB.Production.ProductModel PM
ON PP.ProductModelID = PM.ProductModelID
FULL JOIN AdventureWorksDB.Purchasing.ProductVendor PV
ON PP.ProductID = PV.ProductID
FULL JOIN AdventureWorksDB.Purchasing.Vendor V
ON PV.BusinessEntityID = V.BusinessEntityID
FULL JOIN AdventureWorksDB.Person.BusinessEntity BE
ON V.BusinessEntityID = BE.BusinessEntityID
FULL OUTER JOIN AdventureWorksDB.Person.Person P
ON BE.BusinessEntityID = P.BusinessEntityID
WHERE PP.SellStartDate = '2007-07-01'
And the output:
ModelName |Customer Name
--------------------------------------
All-Purpose Bike Stand | NULL
Bike Wash | NULL
Chain | NULL
Classic Vest | NULL
Fender Set - Mountain | NULL
Front Brakes | NULL
Front Derailleur | NULL
Hitch Rack - 4-Bike | NULL
HL Bottom Bracket | NULL
...
etc.