Reputation: 2503
I am using following tables from adventure work to write a query:
The table FactInternetSales table has FK OrderDateKey, DueDateKey and ShipDateKey Assosiate with DateKey in DimDate table.
I have wrote following query to test:
SELECT dd.DateKey, dd.EnglishMonthName, fis.TotalProductCost
FROM DimDate AS dd INNER JOIN FactInternetSales AS fis
ON dd.DateKey = fis.OrderDateKey AND dd.DateKey = fis.DueDateKey
AND dd.DateKey = fis.ShipDateKey
Above query produces empty output. I've checked the data in the FactInternetSales table and it has FK that associates with PK in the DimDate Table.What would be possible cause of this problem?
Please advise? Thanks in advance!
Upvotes: 0
Views: 692
Reputation: 62831
While this is extremely difficult to understand without having the Adventure Works Database (and I can't see your attached image), my guess is that FactInternetSales should only JOIN DimDate ON a single field. Currently, the way you have the query written, you are joining DimDate.DateKey = FactInternetSales.OrderDateKey = FactInternetSales.DueDateKey = FactInternetSales.ShipDateKey
Unless those 3 fields in FactInternetSales are the same, this will never produce results.
Instead try something like:
SELECT dd.DateKey, dd.EnglishMonthName, fis.TotalProductCost
FROM DimDate AS dd INNER JOIN FactInternetSales AS fis
ON dd.DateKey = fis.OrderDateKey
Good luck.
Upvotes: 3