日期:2014-05-18 浏览次数:20504 次
select * from T1 a where not exists(select 1 from T1 where name=a.name and recordTime>a.recordTime)
------解决方案--------------------
row_number()over(partition by order by )
------解决方案--------------------
select * from t1 a where not exists(select 1 from t1 where abs(datediff(mi,recordtime,getdate()))<abs(datediff(mi,a.recordtime,getdate()))
------解决方案--------------------
select top 1 * from t1 order by recordTime desc
------解决方案--------------------
和 当前日期做 差,取差值最小的
------解决方案--------------------
select DATEDIFF(ms,GETDATE(),getdate()+1)---毫秒
select DATEDIFF(day,GETDATE(),getdate()+1)---天
select DATEDIFF(HOUR,GETDATE(),getdate()+1)---小时
select DATEDIFF(Minute,GETDATE(),getdate()+1)---分钟
select DATEDIFF(Second,GETDATE(),getdate()+1)---秒