+ -
当前位置:首页 → 问答吧 → ASP怎么从access中判断NUm字段,连续的三条一样的?

ASP怎么从access中判断NUm字段,连续的三条一样的?

时间:2011-06-22

来源:互联网

例如从下列数据记录中取出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

作者: fuli512   发布时间: 2011-06-22

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

作者: ACMAIN_CHM   发布时间: 2011-06-22

select top 3 * from table where ID>=8 order by id asc

作者: tcwsyt   发布时间: 2011-06-22