select case when datepart(month,outdate) = 1 then 12 else mon-1 end from ctilog

解决方案 »

  1.   

    select case datepart(month,outdate) when 1 then 12 else mon-1 end from ctilog
    或:
    select dateadd(month,-1,outdate) from ctilog
      

  2.   

    select case datepart(month,outdate) when 1 then 12 else mon-1 end from ctilog
    或:
    select month(dateadd(month,-1,outdate)) from ctilog
      

  3.   

    select month(dateadd(month,-1,getdate()))
      

  4.   

    select case datepart(month,outdate) when 1 then 12 else datepart(month,outdate) - 1 end from ctilog
      

  5.   

    select month(dateadd(month,-1,outdate)) from ctilog