SQL- Sub Query and Correlated Sub Query

Why we need sub queries?

The reason is to avoid writing multi-queries.

There are 2 types. Sub query and Correlated Sub Query.

EMP Table:

empname empno sal

abcd        101        2000

abbb      102        10000

select ename from emp a

where sal=(select max(sal) from emp b);

The result: abbb

The aproach is IN-OUT. That means first it executes internal query and then outer query executes.

In my next post I will write Correlate query and examples.


Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.