Select 
  '集团年进',
  Cast(DatePart(Year,StartDate) As Varchar(4))+'年12月31日', b.level
  
From Employee,(Select Top 1 Level From Education Where Badge=Employee.Badge And ToDate<Employee.StartDate Order by ToDate Desc) b
Where Company='集团' And StartDate Is Not Null
Group by Cast(DatePart(Year,StartDate) As Varchar(4))+'年12月31日',b.level

解决方案 »

  1.   

    TRY:select * from Employee aa where not exists(select 1 from Employee bb where aa. Badge=bb. Badge and  bb.todate<aa.startdate and aa.startdate <bb.startdate )
      

  2.   

    select max(aa),bb,cc 
    from (
    Select 
      '集团年进' as aa ,
      Cast(DatePart(Year,StartDate) As Varchar(4))+'年12月31日' as bb ,  
      (Select Top 1 Level From Education Where Badge=Employee.Badge And ToDate<Employee.StartDate Order by ToDate Desc) as cc
    From Employee
    Where Company='集团' And StartDate Is Not Null
    ) a group by bb,cc