现在有个判断:
  字段有:最后工作日
需要增加的条件是这样的:
    判断最后工作日是否为空 ,不为空取最后工作日,为空取这个条件DATEDIFF(mm,到职日期,a01a3)>=3
   怎么写?

解决方案 »

  1.   


    select isnull(最后工作日,DATEDIFF(mm,到职日期,a01a3)) from tab
      

  2.   

    where 最后工作日 is not null 
    or DATEDIFF(mm,到职日期,a01a3)>=
      

  3.   

    不为空 就不用判断DATEDIFF(mm,到职日期,a01a3)>=3,在为空的情况下,用这个条件来判断DATEDIFF(mm,到职日期,a01a3)>=3
    where  d.pid=c.person_id and kq_a01.a0190=员工编号
    and ISNULL(Dimission,0)=1  and backtype not like '%挂失%' 
    and DATEDIFF(mm,到职日期,a01a3)>=3 and datediff(MM,a01a3,GETDATE())<=1是一部分代码 ,需要添加条件的地方
      

  4.   

    where d.pid=c.person_id and kq_a01.a0190=员工编号
    and ISNULL(Dimission,0)=1 and backtype not like '%挂失%'  
    and (最后工作日 is not null or DATEDIFF(mm,到职日期,a01a3)>=3 and datediff(MM,a01a3,GETDATE())<=1)