What is correlated sub-query?

Answer Posted / asnani_satish@yahoo.com

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,sum(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". The query is behaving as a temporary table.

Is This Answer Correct ?    15 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between function and trigger?

535


When is a declare statement required?

665


How do I delete a trigger?

531


What does where 1 1 mean in sql?

533


How many functions are there in sql?

530






What are the types of queries in sql?

512


Can sql developer connect to db2?

576


what is the command line end user interface - mysql? : Sql dba

494


What is difference between db2 and sql?

522


What is percent sign in sql?

709


What is an intersect?

643


what is uncommittable transactions? : Transact sql

554


How sql query is executed?

546


What is vector point function?

555


How do you modify a trigger?

518