不好意思我了一个s 应该是: select * from table where datediff(minute,AddTime,getdate())<=20
select * from t where datediff(mi,AddTime,getdate()) between 0 and 20
select * from 表 where datediff(minute,AddTime,getdate()) between 0 and 20
select * from 表 where datediff(mi,AddTime,getdate()) <= 20
select * from table_name where AddTime=>getdate() and AddTime<=dateadd(mi.-20,getdate())这样也可以:)
select * from 表 where datediff(mi,AddTime,getdate()) <= 20 下面这个效率低 select * from table_name where AddTime=>getdate() and AddTime<=dateadd(mi.-20,getdate())
先给给addtime作个索引 然后 select * from table_name where AddTime<=getdate() and AddTime>dateadd(minute,-20,getdate())效率会好点
应该是:
select * from table where datediff(minute,AddTime,getdate())<=20
*
from
表
where
datediff(minute,AddTime,getdate()) between 0 and 20
from table_name
where AddTime=>getdate() and AddTime<=dateadd(mi.-20,getdate())这样也可以:)
下面这个效率低
select *
from table_name
where AddTime=>getdate() and AddTime<=dateadd(mi.-20,getdate())
然后
select *
from table_name
where AddTime<=getdate() and AddTime>dateadd(minute,-20,getdate())效率会好点