Select Rownum From dual Connect By Rownum <= '4' ;
使用此SQL列出1到4之间的数字。
我想列出1到4个跳过3.以便结果看起来像
1
2
4
请帮助
答案 0 :(得分:1)
SELECT CASE WHEN LEVEL < 3 THEN LEVEL ELSE LEVEL + 1 END AS value
FROM DUAL
CONNECT BY LEVEL < 4;
或
SELECT *
FROM (
SELECT LEVEL AS value
FROM DUAL
CONNECT BY LEVEL <= 4
)
WHERE value <> 3;
或者,由于目前还不清楚你的序列应该如何超越4,你可以这样做:
SELECT POWER( 2, LEVEL - 1 ) AS value
FROM DUAL
CONNECT BY LEVEL <= 3;