我目前有一个表格(示例快照):
Employee ID Old Value New Value Update Date
1 Analyst non-employee 10/1/2012
1 non-employee Senior Analyst 10/1/2012
2 Analyst non-employee 9/1/2012
2 non-employee Assistant Mgr. 9/1/2012
2 Assistant Mgr. non-employee 10/1/2015
2 non-employee Manager 10/1/2015
3 Analyst non-employee 10/1/2015
3 non-employee Manager 10/1/2015
4 Analyst non-employee 9/1/2012
4 non-employee Senior Analyst 9/1/2012
4 Senior Analyst non-employee 10/1/2015
4 non-employee Assistant Mgr. 10/1/2015
4 Assistant Mgr. non-employee 10/6/2015
4 non-employee Manager 10/6/2015
从这张表中,我需要选择那些直接从分析师转变为经理的员工ID,即。没有成为助理经理或高级分析师。
期望的结果:
Employee ID Old Value New Value Update Date
3 Analyst Manager 10/1/2015
我在访问中运行了以下查询以获得所需的结果:
select t.id, t.oldvalue, tnext.newvalue, t.updatedate
from table t inner join
table tnext
on t.employeeid = tnext.employeeid and
t.updatedate = tnext.updatedate and
t.newvalue = 'non-employee' and
tnext.oldvalue = 'non-employee'
where t.oldvalue = 'Analyst' and tnext.newvalue = 'Manager';
我收到错误,因为查询的t.newvalue='non-employee'
部分突出显示不支持Join表达式。我搜索了这个问题,但我无法弄清楚问题。任何帮助将非常感激!谢谢!
答案 0 :(得分:0)
在加入条件下,尝试更改
tnext.oldvalue = 'non-employee'
到
tnext.oldvalue = 'non-member'
我认为这应该可以解决你的问题。
答案 1 :(得分:0)
感谢帮助人......我想我找出了问题所在。我必须以MS Access“可接受”的格式编写查询。 我写了这个查询,它起作用了:
选择a1.uid,a1.oldvalue,a2.newvalue,a1.updatedate
FROM Table1 AS a1 INNER JOIN
(选择Table1.uid,Table1.oldvalue,Table1.newvalue,Table1.updatedate FROM Table1,Table1.oldvalue =“Non-Employee”AND Table1.newvalue =“Manager”)AS a2
ON(a1.updatedate = a2.updatedate)AND(a1.uid = a2.uid)
WHERE(((a1.oldvalue)=“Analyst”)AND((a1.newvalue)=“非员工”));