根据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,表的顺序应颠倒如下 -
WITH CTE2 AS
(
SELECT top 10 X FROM CTE1
),
CTE1 AS
(
SELECT
X
FROM SomeTable
)
SELECT * FROM CTE2