年修计算

来源:互联网 发布:软件人才外包ren 编辑:程序博客网 时间:2024/05/16 11:57

declare @人员 table (ID int,XM varchar(20),工龄 int)
insert @人员
select 1,'a',3
union all select
2,'b',5
union all select
3,'c',6
union all select
4,'d',7
union all select
5,'e',9

declare @人员休息天数 table (
ID int,
工龄 int,
年休天数 int
)
insert @人员休息天数 select
1,     5,        3
union all select
2,     7 ,       5
union all select
3,     10 ,      7
union all select
4,     11  ,     10

select a.*,b.年休天数
from @人员 a,@人员休息天数 b
where a.工龄<=b.工龄
and not exists (
select 1 from @人员休息天数
where 工龄<b.工龄
and 工龄>=a.工龄
)


 

原创粉丝点击