Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Merry Christmas: draw a Christmas tree with GaussDB T and discuss the syntax compatibility of Gauss database

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report