SQL: Join, Aliases and Set Operators, Union, Intersect, Minus and NESTED Queries
SQL: Join, Aliases and Set Operators, Union, Intersect, Minus and NESTED Queries
10
SQL: Join, Aliases and Set Operators, union, Intersect, Minus and NESTED
Queries
LAB TASK
1. Create a query that displays ename, deptno, and all enames of those employees
who work in the same department as a given employee. Give each column an
appropriate Label.
2. Create a query that displays enames, deptno, and hiredates of all employees
hired after employee MARTIN.
SELECT ENAME,DEPTNO,HIREDATE FROM EMP WHERE HIREDATE
<=(SELECT HIREDATE FROM EMP WHERE ENAME=’Sara’);
3. Create a query that displays enames, deptno, and hiredates for all employees
who were hired before their managers, alongwith their manager‘s names and
hiredates. Give the columns with appropriate labels.
Write a query to display the enames, sal and mgr of every employee
whose mgr is KING and sal is greater than 800.
SELECT ENAME,SAL,MGR FROM EMP WHERE MGR=’7839’ AND SAL>800;
2.