我有数据,其中两列[Previous State]
和[Next State]
包含来自相同州列表的值。
我有一个单独的表,其中有两列将这些状态映射到更新的状态名称,如下所示:
State | Mapped State |
--------+--------------+
1 | a |
2 | b |
3 | b |
4 | c |
5 | d |
我想在查询中提取显示相对[Previous State]
值的[Next State]
和[Mapped State]
。
当我两次加入状态映射表时,我抛出的代码错误:
SELECT a.[Name], b.[Mapped State] as [Previous State Mapped], c.[Mapped State] AS [Next State Mapped]
FROM [Raw Data] a
JOIN [Mapping Table] b ON a.[Previous State]=b.[State]
JOIN [Mapping Table] c ON a.[Next State]=c.[State]
为什么这不起作用?感谢