Oracle数据库 - 选择最少的选择结果

use*_*659 0 sql database oracle select

我想获得select语句返回的列的最小值:

select lead(place) over (order by place) - place as gap
from viewers
Run Code Online (Sandbox Code Playgroud)

我想用where子句来做,但显然我不能在条件中引用我的'gap'列.

Ara*_*llo 6

你必须作为子查询来做:

select min(gap) from (
select lead(place) over (order by place) - place as gap
from viewers)
Run Code Online (Sandbox Code Playgroud)