16,748
社区成员
发帖
与我相关
我的任务
分享
create table #Ftest(--晋级管理表
Fid int identity(1,1) primary key,
Flevel int,--级别
Fyear int --年限
)
insert into #Ftest
select 1,0 union all
select 2,2 union all
select 3,5 union all
select 4,7
create table #emp(
Eid int identity(1,1) primary key,
Eenterdate datetime,
Elevel int
)
insert into #emp
select '2001-1-1',1 union all
select '2003-1-1',1 union all
select '2005-1-1',1 union all
select '2008-1-1',1 union all
select '2010-1-1',1 union all
select '2012-10-1',1
update #emp set Elevel = f.Flevel from #emp e inner join #Ftest f
on datediff(month,Eenterdate,getdate())/12
>= f.Fyear
select *,datediff(month,Eenterdate,getdate())/12 from #emp
感觉有点和这个类似吧。