如何查到时间早于指定日期的最后一次上线时间段 例如,要查2001-5-23日所有手机最后一次上线时间 想得到如下结果 1111 2001-5-20 2001-5-21 1166 2001-4-30 2001-5-22 4433 2001-5-1 2001-5-5 1688 2001-1-1 NULL //这个手机从2001-1-1到现在一直在线,因此离线时间为空SQL code: select id,onlinetime,offlinetime from ( select idd=row_number()over(partition by id order by onlinetime desc),* from t )tt where idd=1
he OVER SQL construct or statement is not supported. 为什么不支持,我的是SQL2000 说实话 测试数据给得不够 SQL code: select id,onlinetime,offlinetime from TB t where not exists(select 1 from TB where t.id=id and t.onlinetime<onlinetime) and isnull(offlinetime,getdate())<='2001-5-23'
运行后报错误如下: 错误类型: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 '数学 + 4where 姓名='王静'' 中。 ......