teradata 中的多个公用表表达式

问题描述 投票:0回答:1

根据this teradata v14.0支持多个公共表表达式。所以简化的脚本如下:

WITH CTE1 AS
(
    SELECT       
                X                                       
        FROM SomeTable
)
,CTE2 AS
(
        SELECT top 10 X FROM CTE1
)
SELECT * FROM CTE2

应该可以。不幸的是,我得到:

Object 'CTE1' does not exist.

有什么想法吗?

teradata
1个回答
0
投票

对于 Teradata,表的顺序应颠倒如下 -

WITH CTE2 AS
(
        SELECT top 10 X FROM CTE1
),
CTE1 AS
(
    SELECT       
                X                                       
        FROM SomeTable
)
SELECT * FROM CTE2
© www.soinside.com 2019 - 2024. All rights reserved.