=> A query embedded in another Query or Sub Query.
=> Queries can be nested upto 255 level.
Syntax:
=> Select ....
( select ....
( select ....
Examples:
1. Select 2nd max salary ?
=> Select MAX( sal ) from emp where sal < ( Select MAX( sal ) from emp );
2. Find the Location of the employee who is earning 2nd max sal ?
=> Select loc from dept where deptno in ( select deptno from emp where sal = (
Select MAX( sal ) from emp where sal < ( Select MAX( sal ) from emp ) ) );
=> Queries can be nested upto 255 level.
Syntax:
=> Select ....
( select ....
( select ....
Examples:
1. Select 2nd max salary ?
=> Select MAX( sal ) from emp where sal < ( Select MAX( sal ) from emp );
2. Find the Location of the employee who is earning 2nd max sal ?
=> Select loc from dept where deptno in ( select deptno from emp where sal = (
Select MAX( sal ) from emp where sal < ( Select MAX( sal ) from emp ) ) );
No comments:
Post a Comment