Practice 5--Querying Multiple Tables
Practice 5--Querying Multiple Tables
1. Write a query to display the name, department number, and department name for
all employees.
14 rows selected.
2. Create a unique listing of all jobs that are in department 30. Include the location of department 30
in the output.
JOB LOC
--------- -------------
CLERK CHICAGO
MANAGER CHICAGO
SALESMAN CHICAGO
3. Write a query to display the employee name, department name, and location of all
employees who earn a commission.
4. Display the employee name and department name for all employees who have an A in their
name.
ENAME DNAME
------- ------------
BLAKE SALES
CLARK ACCOUNTING
MARTIN SALES
ALLEN SALES
JAMES SALES
WARD SALES
ADAMS RESEARCH
7 rows selected.
5. Write a query to display the name, job, department number, and department name for all
employees who work in DALLAS.
6. Display the employee name and employee number along with their manager’s name and
manager number. Label the columns Employee, Emp#, Manager, and Mgr#, respectively.
8. Create a query that will display the employee name, department number, and all the
employees that work in the same department as a given employee. Give each column an
appropriate label.
DEPARTMENT EMPLOYEE COLLEAGUE
---------- -------- ---------
10 CLARK KING
10 CLARK MILLER
10 KING CLARK
10 KING MILLER
10 MILLER CLARK
10 MILLER KING
20 ADAMS FORD
20 ADAMS JONES
20 ADAMS SCOTT
20 ADAMS SMITH
20 FORD ADAMS
20 FORD JONES
20 FORD SCOTT
...
56 rows selected.
9. Show the structure of the SALGRADE table. Create a query that will display the name, job,
department name, salary, and grade for all employees.
10. Create a query to display the name and hire date of any employee hired after employee Blake.
ENAME HIREDATE
------- ---------
KING 17-NOV-81
CLARK 09-JUN-81
MARTIN 28-SEP-81
TURNER 08-SEP-81
JAMES 03-DEC-81
FORD 03-DEC-81
SCOTT 09-DEC-82
ADAMS 12-JAN-83
MILLER 23-JAN-82
9 rows selected.
11. Display all employees’ names and hire dates along with their manager’s name and hire date
for all employees who were hired before their managers. Label the columns Employee, Emp
Hiredate, Manager, and Mgr Hiredate, respectively.