我试图弄清楚如何使以下查询工作。 Teradata给我的消息是找不到派生表GLT_Yearly
。本质上,我试图在左侧联接中将GLT_Yearly
操纵为BD
,然后对其进行联接。我正在尝试做的事情是否可行,或者有更好的方法来解决?谢谢!
SELECT
FROM
(SELECT
FROM
(SELECT
FROM
(SELECT
FROM
)AS GLT0
)AS GLT1
)AS GLT_Yearly
LEFT JOIN
(SELECT
FROM GLT_Yearly) AS BD
ON Account = BD.Account
答案 0 :(得分:1)
使用CTE:
WITH GLT_Yearly as (
SELECT
FROM (SELECT
FROM (SELECT
FROM
) GLT0
) GLT1
)
SELECT
FROM GLT_Yearly LEFT JOIN
GLT_Yearly BD
ON GLT_Yearly.Account = BD.Account;
子查询的别名可用于标识列。但是,它不能用作对子查询本身的第二个引用。为此,请使用CTE>