我正在尝试从不同的表中加入不同的数据类型。我以为我的语法正确但显然我一定做错了。
语法错误表示表达式中的类型不匹配,所以我确定我没有正确转换数据类型
这是我的加入
SELECT CLng([Inventory].ItemID) AS [Item#],
Sum([Invoice].Quantity) AS [Order QTY]
FROM [Invoice] INNER JOIN [Inventory] ON [Invoice].ItemID = CLng([Inventory].ItemID)
WHERE ((([Invoice].OrderNumber) BETWEEN 1 And 23))
GROUP BY CLng([Inventory].ItemID);
答案 0 :(得分:1)
为什么在里面()?尝试删除并将数字转换为str
SELECT CLng([Inventory].ItemID) AS [Item#],
Sum([Invoice].Quantity) AS [Order QTY]
FROM [Invoice] INNER JOIN [Inventory] ON Str ( [Invoice].ItemID) = [Inventory].ItemID
WHERE [Invoice].OrderNumber) BETWEEN 1 And 23
GROUP BY CLng([Inventory].ItemID);
或
SELECT CLng([Inventory].ItemID) AS [Item#],
Sum([Invoice].Quantity) AS [Order QTY]
FROM [Invoice] INNER JOIN [Inventory] ON CLng( Str ( [Invoice].ItemID)) = CLng( [Inventory].ItemID)
WHERE [Invoice].OrderNumber) BETWEEN 1 And 23
GROUP BY CLng([Inventory].ItemID);