Let consider the given partial relation EMP. Let us make some sub-queries for them
EMPNO
|
ENAME
|
JOB
|
SAL
|
DEPTNO
|
7566
|
Nirmal
|
MANAGER
|
2975
|
10
|
7788
|
Kailash
|
ANALYST
|
3000
|
10
|
7839
|
Karuna
|
PRESIDENT
|
5000
|
20
|
7902
|
Ashwin
|
ANALYST
|
3000
|
20
|
7905
|
Ashwini
|
MANAGER
|
4000
|
20
|
Example: Get the details of the people having the minimum salary.
SELECT ENAME, JOB, SAL
FROM EMP
WHERE SAL = ( SELECT MIN (SAL) FROM EMP);
Output:
ENAME
|
JOB
|
SAL
|
Nirmal
|
MANAGER
|
2975
|