怎么找出指定时间上一个时间段的记录
如有 id time
1 2007-01-01
1 2007-05-06
2 2007-02-02
2 2007-05-08
如何找出2007-05-05时间之前的数据,即:
id time
1 2007-01-01
2 2007-02-02
------解决方案--------------------select a.* from tb a ,
(select id , max(time) as time from tb where time < '2007-05-05 ') b
where a.id = b.id and a.time = b.time