sql server 2008怎么用SQL语句查询索引碎片
发布网友
发布时间:2022-04-22 01:11
我来回答
共1个回答
热心网友
时间:2022-04-09 16:41
用这个语句,必能达到你想要的效果,将字段名换一下,id-序号,state-状态,num-数值,test-表名
select
*
from
test
where
state='上升'
and
num>0
and
rownum=1
union
all
select
b.id,b.state,b.num
from
(select
row_number()
over(order
by
id)
rn,
id,state,num
from
test
a
where
state='上升'
and
num>0)
a
inner
join
(select
row_number()
over(order
by
id)
rn,id,state,num
from
test
a
where
state='上升'
and
num>0)
b
on
a.rn+1=b.rn
where
b.id<>a.id+1