Could anyone clearly explain the diference between sub
query and correlated sub query?
Answers were Sorted based on User's Feedback
Correlated subquery runs once for each row selected by the
outer query. It contains a reference to a value from the
row selected by the outer query.
Nested subquery runs only once for the entire nesting
(outer) query. It does not contain any reference to the
outer query row.
For example
Correlated Subquery:
select e1.empname e1.basicsal e1.deptno from emp e1 where
e1.basicsal (select max(basicsal) from emp e2 where
e2.deptno e1.deptno)
Nested Subquery:
select empname basicsal deptno from emp where (deptno
basicsal) in (select deptno max(basicsal) from emp group by
deptno)
Please let me know if I am wrong...............
| Is This Answer Correct ? | 2 Yes | 0 No |
Correlated subquery runs once for each row selected by the
outer query. It contains a reference to a value from the
row selected by the outer query.
Nested subquery runs only once for the entire nesting
(outer) query. It does not contain any reference to the
outer query row.
For example
Correlated Subquery:
select e1.empname e1.basicsal e1.deptno from emp e1 where
e1.basicsal (select max(basicsal) from emp e2 where
e2.deptno e1.deptno)
Nested Subquery:
select empname basicsal deptno from emp where (deptno
basicsal) in (select deptno max(basicsal) from emp group by
deptno)
Please let me know if I am wrong...............
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / praveen
if we want to select 100th hig no.
in sub-query we will write 100 conditions.
to avoid this we go for correlated sub-query
| Is This Answer Correct ? | 0 Yes | 0 No |
What is sqlcode -811?
7 Answers Accenture, CTS, TCS,
what is the differences between spufi and qmf and which is better?
4 Answers Accenture, Cap Gemini,
For a db2 column that is being defined as decimal (11, 2), discuss the cobol picture clause.
What is an alias?
What is db2 bind process?
One program calling 5 subprograms, its a cobol db2 program, after precompilation how many plans and packages will created?
Is ibm db2 free?
How to fetch the last row from the table in SQL (db2)?
What is DCLGEN ?
What is null indicator in cobol db2?
How to find the number of rows in db2 tables?
How to resolve SQL Code -310. The db table feild is declared as Decimal(7,2).