哈哈哈哈,我自己解决了,不过还是谢谢各位的热心参与,现将语句公布如下: select case when frequ_code='QOD1' and day(getdate())%2=1 then 序列号 when frequ_code='QOD2' and day(getdate())%2=0 then 序列号 when frequ_code='TIW2' and datepart(dw,getdate()) in (3,5,7) then 序列号 when frequ_code='TIW1' and datepart(dw,getdate()) in (2,4,6 ) then 序列号 when frequ_code not in ('QOD1','QOD2','TIW1','TIW2') then 序列号 end from aaa 希望能给大家以启发。注,我这里不仅判断了单、双日,还判断了一周三次的情况哦。 如果大家有改进或优化的方案,请提出指教。
select case when frequ_code='QOD1' and day(getdate())%2=1 then 序列号
when frequ_code='QOD2' and day(getdate())%2=0 then 序列号
when frequ_code='TIW2' and datepart(dw,getdate()) in (3,5,7) then 序列号
when frequ_code='TIW1' and datepart(dw,getdate()) in (2,4,6 ) then 序列号
when frequ_code not in ('QOD1','QOD2','TIW1','TIW2') then 序列号
end from aaa
希望能给大家以启发。注,我这里不仅判断了单、双日,还判断了一周三次的情况哦。
如果大家有改进或优化的方案,请提出指教。