加好友 发短信
等级:超级版主
帖子:110562
积分:562700
威望:0
精华:9
注册:2015/6/24 9:21:00
|
Post By:2020/5/21 17:31:00 [显示全部帖子]
Select e.姓名,f.职务,f.任职时间,g.原职务,g.原任职时间 from ({基本情况表} As e Inner join (select a.编号,a.职务,a.任职时间 from {职务表} as a left join (Select 编号,max(任职时间) As 任职时间 from {职务表} group by 编号) as b on a.编号=b.编号 where a.任职时间 = b.任职时间) as f on e.编号=f.编号) left join (select c.编号,c.职务 as 原职务,c.任职时间 as 原任职时间 from {职务表} as c inner join (Select a.编号,max(a.任职时间) as 任职时间 from {职务表} As a Inner join (Select 编号,max(任职时间) As 任职时间 from {职务表} group by 编号) As b on a.编号=b.编号 where a.任职时间 <> b.任职时间 group by a.编号) as d on c.编号=d.编号 where c.任职时间 = d.任职时间) as g on e.编号=g.编号没有添加工资表,自己参考着做
|
|