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

How many types of relationship are there?

535


What is primary key sql?

527


What is anonymous block in sql?

627


Why do we need a foreign key?

536


Define union, minus, union all, intersect ?

541






How do you drop a trigger?

533


What is a record in pl/sql?

535


What is execute immediate?

538


How do you declare a user-defined exception?

522


What is memory optimized?

538


Is sql a programming?

533


Which join is like an inner join?

515


What is a temporal table?

480


Explain the difference between sql and mysql.

548


what are wild cards used in database for pattern matching ? : Sql dba

533