有一个表 A用户工号 用户姓名 考核年度 考核结果我想找出最近三年年度考核为称职或者优秀的职工,用SQL语句怎么写啊?

解决方案 »

  1.   

    select * from A where 考核年度 in(year(getdate()),year(getdate())-1,year(getdate())-2) and 考核结果 in('称职','优秀')
      

  2.   

    借一下楼上的想法
    select * from 
    (select 用户工号,count(*) as [count] from 
    (select * from A where 考核年度 in(year(getdate()),year(getdate())-1,year(getdate())-2) and 考核结果 in('称职','优秀')) as B
    group by 用户工号) as C where [count]=3
      

  3.   

    select * from A where 考核年度 in('2003','2004','2005') and 考核结果 in('称职','优秀')