我正在开发SQL或PL / SQL中的Query,如下所示。我尝试过以下查询
SELECT RPAD ('* ', LEVEL*2, '* ')
FROM DUAL
CONNECT BY LEVEL <= 5
UNION all
SELECT RPAD ('* ', LEVEL*2, '* ')
FROM DUAL
CONNECT BY LEVEL <= 5;
但我得到的输出就是这种形式。
*
* *
* * *
* * * *
* * * * *
*
* *
* * *
* * * *
* * * * *
但我需要的输出格式是
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
任何人都可以帮我这个。
答案 0 :(得分:1)
这个怎么样:
SELECT RPAD ('* ', LEVEL*2, '* ')
FROM DUAL
CONNECT BY LEVEL <= 5
UNION all
SELECT RPAD ('* ', (5-LEVEL)*2, '* ')
FROM DUAL
CONNECT BY LEVEL <= 5;
答案 1 :(得分:0)
我认为这是正确的。
SELECT RPAD (' ', LEVEL*2, ' ')
FROM DUAL
CONNECT BY LEVEL <= 5
UNION all
SELECT RPAD (' ', (5-LEVEL)*2, ' ')
FROM DUAL
CONNECT BY LEVEL <= 5-1;
希望它可以帮助你...... !!