Why we need sub queries?
The reason is to avoid writing multi-queries.
There are 2 types. Sub query and Correlated Sub Query.
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.