日期:2014-05-17 浏览次数:20842 次
select * from person where userid='ad' and case when ttlflag=1 and DATEADD(DAY,accountttl,createtime)>GETDATE() then 1 --判定时间 when ttlflag=3 then 1 else 0 end =1 ;
-- TRY IT .. SELECT * FROM PERSON WHERE USERID = 'ad' AND (CASE WHEN TTLFLAG = 1 AND CREATETIME + ACCOUNTTTL = SYSDATE THEN 1 WHEN TTLFLAG = 3 THEN 3 ELSE 0 END) = 1; -- 根据我的想法,可简化之如下: SELECT * FROM PERSON WHERE USERID = 'ad' AND (TTLFLAG = 1 AND CREATETIME + ACCOUNTTTL = SYSDATE);