57,062
社区成员
发帖
与我相关
我的任务
分享select c.id, c.layer,c.name
from table3 c,
(
select a.id,min(b.id) as maxID
from table3 b,
(
select id,layer
from table3
where id=4 --the number you need // liuyann
) a
where b.id>a.id and b.layer<a.layer
group by a.id
) d
where c.id >=d.id and c.id<d.maxidid layer name
1 1 aa
2 2 bb
3 4 dd
4 3 cc
5 6 aa1
6 3 bb1
7 2 cc1
8 3 dd1
9 4 ee1
10 5 ff1
11 2 11
12 2 22
13 3 33id layer name
4 3 cc
5 6 aa1
6 3 bb1id layer name
8 3 dd1
9 4 ee1
10 5 ff1