select *,rn=identity(int,1,1) into # from 企业表 order by 企业编号,年 desc,月 desc
select * from # a where not exists(select 1 from # where 企业编号=a.企业编号 and rn<a.rn)
select *,rn=identity(int,1,1) into # from 企业表 order by 企业编号,年 desc,月 desc
select * from # a where not exists(select 1 from # where 企业编号=a.企业编号 and rn>a.rn)