这样的update能不能改得高效点解决思路
这样的update能不能改得高效点
------解决方案--------------------
应该可以了吧!再不行楼主可以分开更新,条件就是与当前日期的月份差,小于0和大于1分别更新。
------解决方案--------------------
楼主的语句就行了,语句简单没什么可优的
------解决方案--------------------
性能上没啥优化的,语句想看到短,那就把业务逻辑写到函数里面去
------解决方案--------------------
- SQL code
update MarketingCaseExpire set ProjectEndState=case when DATEDIFF(month, getdate() , ProjectEndTime)=0 then '当月到期' when DATEDIFF(month, getdate() , ProjectEndTime)<0 then '已到期' when DATEDIFF(month, getdate() , ProjectEndTime)=1 then '下月到期' when DATEDIFF(month, getdate() , ProjectEndTime)>1 then '2个月后到期' end, CurrentMonthExpire=case when DATEDIFF(month, getdate() , ProjectEndTime)=0 then 1 else 0 end, Expired=case when DATEDIFF(month, getdate() , ProjectEndTime)<0 then 1 else 0 end, TwoMonthsAfterExpired=case when DATEDIFF(month, getdate() , ProjectEndTime)>1 then 1 else 0 end, OneMonthsAfterExpired=case when DATEDIFF(month, getdate() , ProjectEndTime)=1 then 1 else 0 end
------解决方案--------------------
应该可以了吧!再不行楼主可以分开更新,条件就是与当前日期的月份差,小于0和大于1分别更新。
------解决方案--------------------
楼主的语句就行了,语句简单没什么可优的
------解决方案--------------------
性能上没啥优化的,语句想看到短,那就把业务逻辑写到函数里面去
------解决方案--------------------