sql 实现相邻两条数据之差

select a.v1-b.v1 
from (select id,v1 from t2 where id>1) a,
(select id,v1 from t2 where id<>(select max(id) from t2)) b
where a.id=b.id+1

猜你喜欢

转载自hoochiang.iteye.com/blog/2317255