我有一个包含主键Ending Item Code
和外键Starting Item Code
的事实表。主键是左连接到昏暗表项信息表,其中外键也可以。我想要一个列 Dlookup' d 而不是创建另一个查询来加入我的事实表,但我不认为我的语法是正确的,我不能找到有关使用 Dlookup 的人的任何信息。我做错了什么?
特定DLOOKUP代码:
DLOOKUP(" [Descripition] "," [DIM TABLE] ", " FT.[Starting Item Code] = DT.[Item Code] ") AS [Start Item Description]
事实表:
Starting Item Code | Ending Item Code
_____________________________________
1050 1051
昏暗表:
Item Code | Description
_______________________
1050 Chum
1051 Krabby Paddies
SQL代码:
SELECT
FT.Starting Item Code,
FT.Ending Item Code,
DT.Description AS [Ending Item Description],
DLOOKUP(" [Descripition] "," [DIM TABLE] ", " FT.[Starting Item Code] = DT.[Item Code] ") AS [Start Item Description]
FROM [Fact Table] AS FT
LEFT JOIN [Dim Table] AS DT
ON FT.[Ending Item Code] = DT.[Item Code]
我想要的查询结果:
Starting Item Code | Starting Item Description | Ending Item Code | Ending Item Description
____________________________________________________________________________________________
1050 Chum 1051 Krabby Paddies