日期:2014-05-17 浏览次数:20662 次
--SQL
--要是正式工,其最后一次一定为FT
select M.Staff_ID from
(select A.Staff_ID from
(select distinct Staff_ID,Status from TableA where EffectiveDate>'2012-10-01' and EffectiveDate<'2012-10-31') A
group by A.Staff_ID
having COUNT(Status)>1) M inner join
(select *From TableA A where EffectiveDate=
(select MAX(EffectiveDate) EffectiveDate from TableA where Staff_ID = A.Staff_ID)) N
on M.Staff_ID=N.Staff_ID
where N.Status='FT'
--结果集
/*
Staff_ID
CH001
*/