update table set htzt=0 where jssj<(select max(jssj) from table where ryid=?)
update table a set htzt=0 where jssj <(select max(jssj) from table b where b.ryid=a.ryid)
update tb set 合同状态 = 0 from tb t where 结束时间 not in (select max(结束时间) from tb where 人员 = t.人员)
update tb t set 合同状态 = 0 where 结束时间 not in (select 结束时间 from (select max(z.结束时间) 结束时间 ,z.人员id from tb z where z.人员id = t.人员id))
1.只更新当前人员的合同状态为0 update contracts t set flag='0' where jssj < (select max(jssj) from das_aaa where ryid=?) 2.更新所有人员的合同状态为0 update contracts t set flag='0' where jssj < (select max(jssj) from das_aaa where ryid=t.ryid)
cursor c_maxsj Is select 人员id,max(结束时间) maxEnd from 合同表 group by 人员id; Begin for t_maxsj in c_maxsj loop update 合同表 set 合同状态 = 0 where 人员id = t_maxsj.人员id and 结束时间 < t_maxsj.maxEnd; end loop; end;
update tb a set a.合同状态 = '0' where a.结束时间 < (select max(b.结束时间) from tb b where a.人员编号 = b.人员编号 and a.开始时间 = b.开始时间)
update tb set 合同状态 = 0 from tb t where 结束时间 not in (select max(结束时间) from tb where 人员 = t.人员)
where 结束时间 not in (select 结束时间 from (select max(z.结束时间) 结束时间 ,z.人员id from tb z where z.人员id = t.人员id))
update contracts t set flag='0' where jssj < (select max(jssj) from das_aaa where ryid=?)
2.更新所有人员的合同状态为0
update contracts t set flag='0' where jssj < (select max(jssj) from das_aaa where ryid=t.ryid)
select 人员id,max(结束时间) maxEnd
from 合同表
group by 人员id;
Begin
for t_maxsj in c_maxsj loop
update 合同表
set 合同状态 = 0
where 人员id = t_maxsj.人员id
and 结束时间 < t_maxsj.maxEnd;
end loop;
end;