Merry Christmas: draw a Christmas tree with GaussDB T and discuss the syntax compatibility of Gauss database
In the twinkling of an eye is the Christmas holiday, I wish you all a happy holiday. Draw a Christmas tree with GaussDB T (that is, GaussDB 100), pure domestic, more festive.
Without much to say, the picture above:
SQL is as follows:
SELECT
CASE WHEN ENMOTECH = 1 THEN lpad ('*'
GAO
'')
ELSE lpad (''
GAO + 1-ENMOTECH
'') | | rpad ('*'
Lag (ENMOTECH) OVER (PARTITION BY 1)
ORDER BY
ENMOTECH) + ENMOTECH-2
'*')
Merry Christmas, END.
FROM
(SELECT
LEVEL ENMOTECH
MAX (LEVEL) OVER (PARTITION BY 1) GAO
FROM dual
CONNECT BY LEVEL
< 19 ) UNION ALL SELECT lpad(lpad('*',3,'*'),19) FROM dual CONNECT BY LEVEL < 5; 主要,这段 SQL 代码,和 Oracle 完全兼容,在 Oracle 中执行效果如下:
To sum up, GaussDB works very happily after using a very special query syntax:
Case When
LAG analysis function
CONNECT by
Of course, Elder Yang said, my Christmas tree is not very good-looking. He drew a new one according to the company's congratulatory picture. Elder Yang said that the Christmas tree should be like this:
Let's take another picture:
The above code:
WITH leaf AS (
SELECT
Lpad (rpad ('*
(ROWNUM-1) * 2 + 1
'*')
ROWNUM + 20) leaf
ROWNUM
FROM
Dual
CONNECT BY
LEVEL