Anda di halaman 1dari 2

Tutorial 7

SQL Data Manipulation

Consider the EMP and DEPT tables below:

Table Name:
EMP

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO


7369 SMITH CLERK 7902 17-12-1980 800 NULL 20
7499 ALLEN SALESMAN 7698 20-02-1981 1600 300 30
7521 WARD SALESMAN 7698 22-02-1981 1250 500 30
7566 JONES MANAGER 7839 22-04-1981 2975 NULfsL 20
7654 MARTIN SALESMAN 7698 28-09-1981 1250 1400 30
7698 BLAKE MANAGER 7839 01-05-1981 2850 NULL 30
7782 CLARK MANAGER 7839 06-09-1981 2450 NULL 10
7788 SCOTT ANALYST 7566 12-09-1982 3000 NULL 20
7839 KING PRESIDENT NULL 17-11-1981 5000 NULL 10
7844 TURNER SALESMAN 7698 09-12-1981 1500 0 30
7876 ADAMS CLERK 7788 01-12-1983 1100 NULL 20
7900 JAMES CLERK 7698 12-03-1981 950 NULL 30
7902 FORD ANALYST 7566 12-03-1981 3000 NULL 20
7934 MILLER CLERK 7782 23-01-1982 1300 NULL 10

Write SQL statements for the following queries:

1. List all the salesmen name, salary and department no


2. List all salesmen number, job and hiredate
3. Find all the salesmen in department 30
4. Find all the salesmen who have a salary greater than or equal to 1500.
5. List the names of all staffs who are managers
6. List the employee id and names of all staffs who have no assigned manager.
7. List the names of all staffs who has zero commission.
8. List all salesmen name in descending order use order by
9. List all salesmen in descending order of their salary.
10. List the details of employees whose name starts with S
11. List the details of employees whose has the character N in their name.
12. List the details of employees who has the character S as the last in their name.
13. List the details of employees who has L as the second character in their name.
14. Find the total salary paid to all the employees
15. Find the total salary paid to department 10
16. Find the total salary paid to managers
17. Find the maximum salary paid to salesmen
18. Find the average salary paid in the company
19. Find the average salary paid to department 20
20. List the details of all employees whose salary is in the range of 2200 to 2900
21. What is the managers name of department 20
22. List the details of all employees who works for department 20 and earns more
than 2000 as salary
23. How many departments are there in this organization
24. List the details of all employees with salary and commission as one column
(salary + commission)
25. List the details of employees based on department and within department based
on salary
26. How many employees are there in this organization

Anda mungkin juga menyukai