我正在使用adventure中的以下表格来编写查询:

表格FactInternetSales表格具有FK OrderDateKey、DueDateKey和ShipDateKey与DimDate表格中的DateKey相关联。
我写了下面的查询来测试:
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上面的查询产生空输出。我已经检查了FactInternetSales表中的数据,它具有与DimDate Table.What中的PK关联的FK可能是导致此问题的原因?
请给我建议?提前感谢!
发布于 2013-02-02 10:03:56
虽然这是非常难以理解,如果没有冒险工作数据库(我看不到你的附件图像),我的猜测是,FactInternetSales应该只加入DimDate在一个单一的领域。目前,您编写查询的方式是连接DimDate.DateKey = FactInternetSales.OrderDateKey = FactInternetSales.DueDateKey = FactInternetSales.ShipDateKey
除非FactInternetSales中的这3个字段是相同的,否则这永远不会产生结果。
相反,试着这样做:
SELECT dd.DateKey, dd.EnglishMonthName, fis.TotalProductCost
FROM DimDate AS dd INNER JOIN FactInternetSales AS fis
ON dd.DateKey = fis.OrderDateKey 祝好运。
https://stackoverflow.com/questions/14657830
复制相似问题