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 are all the common sql function? : Sql dba

578


How to convert comma separated string to array in pl/sql?

594


What are the parameter modes supported by pl/sql?

528


How to pronounce postgresql?

572


What does fetching a cursor do?

610






What is the primary key?

533


What are the different ddl commands in sql?

574


What are the different datatypes available in PL/SQL?

560


What is break?

614


what are the advantages a stored procedure? : Sql dba

538


What are its different types of dbms?

531


How many scalar data types are supported in pl/sql?

518


What is compiled query?

513


What are the types of functions in sql?

558


What are local and global Indexes and where they are useful.

923