Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Derived Tables - response (1) by asimibm

$
0
0

Hi ,
 
The example that you have shown is perfect example of derived table. The corelated subquery is different. If the SELECT is loacted in WHERE clause then it is subquery and not corelated sub query. In the corelated sub query the select will have some columns from the main query, and if you run alone  the subquery it will give error like column does not exist.
 
SEL * FROM EMP WHERE SALARY=(SEL MAX(SALARY) FROM EMP ); -> example of sub query
SEL * FROM (SEL c1,c2 FROM EMP)dt INNER JOIN DEPT ON EMP.C3=DEPT.C3 WHERE DEPT.C3 IN (SEL C1 FROM DT); -> example of corelated sub query.
The above example might not be correct by syntax.
Thanks


Viewing all articles
Browse latest Browse all 14773

Trending Articles