Reputation: 490
I'm trying to figure out how to make the below query work. Teradata is giving me the message that it can't find the derived table GLT_Yearly
. Essentially, I'm trying to manipulate GLT_Yearly
in the left join as BD
, then join it on itself. Is what I'm trying to do possible or is there a better way to go about it? Thanks!
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
Upvotes: 1
Views: 572
Reputation: 1271151
Use a 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;
The alias for a subquery can be used to identify columns. However, it cannot be used as a second reference to the subquery itself. For that, use a CTE>
Upvotes: 1