create table test(col numeric(10))
Insert into test
select '1'
union all select '3'
union all select '6'
union all select '9'
union all select '15'
union all select '22'
select id=identity(int),col into #t from test
drop table #t
select * from #t
select b.col-a.col col from (select * from #t)a,(select * from #t where id>1)b
where b.id=a.id+1
drop table #t
还是用临时表的好
create table tb(col numeric(10))
Insert into tb
select '1'
union all select '3'
union all select '6'
union all select '9'
union all select '15'
union all select '22'
select id=identity(int,1,1),col into tab from tb
select col=a.col-b.col from (select * from tab where id>1)a
left join tab b on a.id=b.id+1