Sub Query:- Query written with in main query.
Ex:-
SELECT ename
FROM emp
WHERE deptno = (SELECT deptno
FROM dept
WHERE dname= 'XXCSIT')
Nested Query:- Query written with in sub query
Ex:-
SELECT ename
FROM emp
WHERE deptno = (SELECT deptno
FROM dept
WHERE dname= 'XXCSIT'
AND sal > ( SELECT AVG (sal)
FROM dept
GROUP BY deptno
)
)
Co Related Sub Query:- A Sub Query which reference a column already being referenced in main query.
Ex:-
SELECT ename
FROM emp
WHERE deptno = (SELECT deptno
FROM dept d
,emp e
WHERE dname= 'XXCSIT'
AND e.deptno = d.deptno
)
Ex:-
SELECT ename
FROM emp
WHERE deptno = (SELECT deptno
FROM dept
WHERE dname= 'XXCSIT')
Nested Query:- Query written with in sub query
Ex:-
SELECT ename
FROM emp
WHERE deptno = (SELECT deptno
FROM dept
WHERE dname= 'XXCSIT'
AND sal > ( SELECT AVG (sal)
FROM dept
GROUP BY deptno
)
)
Co Related Sub Query:- A Sub Query which reference a column already being referenced in main query.
Ex:-
SELECT ename
FROM emp
WHERE deptno = (SELECT deptno
FROM dept d
,emp e
WHERE dname= 'XXCSIT'
AND e.deptno = d.deptno
)
No comments:
Post a Comment