日期:2014-05-17  浏览次数:20898 次

求个sql语句的写法,关于lead over的
首先根据一些条件取得一个字段,然后再取得这个字段的下一个值,如果此值小于0则继续向下取,根据id排序

关键在于如果小于0怎么处理,目前是这么写的:

select id, depth top, lead( depth, 1 ) over( order by id ) bottom from tab1 where name = 'abc'

------解决方案--------------------