You are on page 1of 5

ASSIGNMENT Batch : 2010-12 Course Code : MS-251 Session : 2011-12 Programme: MBA Semester : III/IV Course Title : DBMS

Lab

List of Practical Exercises (ORACLE)


(Set 1)

Note: Consider the EMP and DEPT tables for the following queries. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. Retrieve a list of MANAGERS. Find out salary of both MILLER and SMITH. Find out the names and salaries of all employees earning more than 1000 per month. Display the names and salaries of all employees except JAMES. Find out the details of employees whose names begin with S. Find out the names of all employees that have A anywhere in their name. Find out the names of all employees that have L as their third character in their name. Find out the names of the employees whose name begin with A or M. Compute yearly salary of SMITH. Compute daily salary of JONES. Calculate the total monthly salary of all employees. Print the average annual salary. Select the name, job, salary, department number of all employees except SALESMAN from department number 30. List unique departments of the EMP table.
SQL> select distinct deptno from emp; DEPTNO --------10 20 30

15.

List the name and salary of employees who can earn more than 1500 and are in department 10 or 30. Label the columns Employee and Monthly Salary respectively.

SQL> SELECT ENAME "NAME",SAL "MONTHLY SALARY" FROM EMP WHERE SAL>1500 AND DEPTNO IN(10,30); NAME MONTHLY SALARY

---------- -------------ALLEN BLAKE CLARK KING 1600 2850 2450 5000

16.

List the name and salary for all employees whose salary is not in the range of 1500 and 2850.
SQL> SELECT ENAME, SAL FROM EMP WHERE SAL<1500 OR SAL>2850; ENAME SAL

---------- --------SMITH WARD JONES MARTIN SCOTT KING ADAMS JAMES FORD MILLER 800 1250 2975 1250 3000 5000 1100 950 3000 1300

10 rows selected.

17.

Display the name and job of all employees who do not have a MANAGER.
SQL> SELECT ENAME, JOB FROM EMP WHERE JOB IN ('MANAGER','PRESIDENT'); ENAME JOB

---------- --------JONES BLAKE CLARK KING MANAGER MANAGER MANAGER PRESIDENT

18.

Display the name, job, and salary of all the employees whose job is MANAGER or ANALYST and their salary is not equal to 1000, 3000, or 5000.
SQL> SELECT ENAME,JOB,SAL FROM EMP WHERE JOB IN('MANAGER','ANALYST') AND SAL <> 1000 AND SAL <> 2000 AND SAL <> 3000; ENAME JOB SAL

---------- --------- --------JONES BLAKE CLARK MANAGER MANAGER MANAGER 2975 2850 2450

19.

Display the name, salary and commission for all employees whose commission amount is greater than their salary increased by 10%.
SQL> select sal,comm from emp where sal/10=comm; no rows selected

20.

Display the name of all employees who have two Ls in their name and are in department 30 or their manager is 7782.
SQL> SELECT ENAME FROM EMP WHERE ENAME LIKE ('%L%L%') AND DEPTNO = 30 OR MGR = 7782; ENAME ---------ALLEN MILLER

21. 22. 23. 24. 25. 26. 27. 28. 29.

Display the names of employees with experience of over 10 years or und 0Count the total number of employees. Retrieve the names of departments in ascending order and their employees in descending order. Find out experience of MILLER. How many different departments are there in the employee table. Find out which employee either work in SALES or RESEARCH department. Print the name and average salary of each department. Select the minimum and maximum salary from employee table. Select the minimum and maximum salaries from each department in employee table. Select the details of employees whose salary is below 1000 and job is CLERK.

ASSIGNMENT Batch : 2010-12 Course Code : 251 Session : 2011-12 Programme: MBA Semester : III/IV Course Title : DBMS Lab

List of Practical Exercises (ORACLE)


(Set 2)

Consider the relations given below: EMPLOYEE (EmployeeID, EmployeeName, Street, City) COMPANY (CompanyID, CompanyName, City) WORKS (EmployeeID, CompanyID, Salary) MANAGES (EmployeeID, ManagerID) I. II. III. IV. 1. 2. 3. 4. 5. 6. 7. 8. Create above relations using your own data types and print the structure of the each relation. Insert at least 10 records in the relation EMPLOYEE and 5 records in the relation COMPANY. Insert appropriate records in the relations WORKS and MANAGES. Print the contents of the each relation. Give an expression in SQL with output for each of the following queries: Find the names of all employees who work for First Bank Corporation. Find the names and cities of residence of all employees who work for the First Bank Corporation. Find the names, street, and cities of residence of all employees who work for First Bank Corporation and earn more than Rs. 10,000/-. Find the employees who live in the same cities as the companies for which they work. Find all employees who live in the same cities and on the same streets as do their managers. Find all employees who do not work for First Bank Corporation. Find all employees who earn more than every employee of Small Bank Corporation. Find all companies located in every city in which Small Bank Corporation is located.

9. 10. 11. 12.

Find all employees who earn more than the average salary of all employees of their company. Find the company that has the most employees. Find the company that has the smallest payroll. Find those companies whose employees earn a higher salary, on average, than the average salary at First Bank Corporation.

You might also like