日期:2014-05-17  浏览次数:20919 次

ASP怎么从access中判断NUm字段,连续的三条一样的?
例如从下列数据记录中取出ID为8、9、10和13、14、15的记录?

ID | chk
-------------------
1 0
2 0
3 1
4 1
5 0
6 1
7 0
8 1
9 1
10 1
11 0
12 0
13 1
14 1
15 1
16 1
17 1
18 0
19 1

------解决方案--------------------
select *
from 下列数据记录 a
where exists (select 1 from 下列数据记录 where chk=1 and ID=a.ID+1)
and exists (select 1 from 下列数据记录 where chk=1 and ID=a.ID+2)
and chk=1
------解决方案--------------------
select top 3 * from table where ID>=8 order by id asc
------解决方案--------------------
select * from tb where id in (8,9,10,13,14,15)