What is correlated sub-query?

Answer Posted / asnani_satish@yahoo.com

Minor correction in above answer
Difference between sub-query, correlated query and query as
table
1. Sub-query : the inner query is executed in entirety
before the outer query is executed
eg select * from emp where deptno in (select deptno from dept);

2. Correlated Query: For each record fetched in outer query
corresponding matching records are fetched in sub-query
because of join condition within inner sub-query. Answers
1,2,3 are correct

3. Query as Table: A query can behave as a table

select a.empno,a.sal,a.sal/b.avgsal*100 as percent_avg_sal
from emp a,(select deptno,avg(sal) avgsal from emp group by
deptno) b
where a.deptno=b.deptno;

Here the entire "(select deptno,avg(sal).....)" behaves as
table named "b" containing dept wise average sal. The query
is behaving as a temporary table.

Is This Answer Correct ?    6 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there a pl/sql pragma similar to deterministic, but for the scope of one single sql select?

754


what is cursor. write example of it. What are the attributes of cursor.

976


Why sql query is slow?

729


How does one load ebcdic data? : aql loader

827


how to analyze tables with 'mysqlcheck'? : Sql dba

719






Can we use having without group by in sql?

732


What is column?

721


Is sql injection illegal?

771


What is a pl/sql block?

759


What is an implicit commit?

762


what is isam? : Sql dba

768


What is rank function in sql?

722


Write a sql select query that only returns each name only once from a table?

757


What is pls integer?

779


How to set up sql*plus output format in oracle?

774