为什么下一个 Fiddle 不给我 102 ?我正在寻找两列中都不存在的最小数字。
注意:一列是数字,另一列是 varchar。
SELECT NVL(MIN(a1.id_int)+1, 111)
FROM bPEOPLE a1
WHERE NOT EXISTS (SELECT 1
FROM PEOPLE a2
WHERE a2.id_int=a1.id_int+1
)
AND NOT EXISTS ( SELECT 1
FROM PEOPLE a3
WHERE TO_NUMBER(a3.id_str)=a1.id_int+1
)
AND a1.id_int + 1 > 100
AND a1.id_int + 1 < 110;