0% found this document useful (0 votes)
126 views

SQL PR PDF

This document contains instructions for a database management systems lab assignment. It lists 29 practical exercises involving SQL queries on Oracle tables EMP and DEPT. The exercises retrieve employee names, salaries, departments and other details based on various conditions. It also provides the schema and sample queries for additional tables EMPLOYEE, COMPANY, WORKS and MANAGES as part of a set 2 of exercises.

Uploaded by

csreddyatsapbi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views

SQL PR PDF

This document contains instructions for a database management systems lab assignment. It lists 29 practical exercises involving SQL queries on Oracle tables EMP and DEPT. The exercises retrieve employee names, salaries, departments and other details based on various conditions. It also provides the schema and sample queries for additional tables EMPLOYEE, COMPANY, WORKS and MANAGES as part of a set 2 of exercises.

Uploaded by

csreddyatsapbi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ASSIGNMENT

Batch : 2010-12 Session : 2011-12 Programme: MBA Semester : III/IV


Course Code : MS-251 Course Title : DBMS Lab

List of Practical Exercises (ORACLE)

(Set 1)

Note: Consider the EMP and DEPT tables for the following queries.

1. Retrieve a list of MANAGERS.


2. Find out salary of both MILLER and SMITH.
3. Find out the names and salaries of all employees earning more than 1000 per
month.
4. Display the names and salaries of all employees except JAMES.
5. Find out the details of employees whose names begin with S.
6. Find out the names of all employees that have A anywhere in their name.
7. Find out the names of all employees that have L as their third character in
their name.
8. Find out the names of the employees whose name begin with A or M.
9. Compute yearly salary of SMITH.
10. Compute daily salary of JONES.
11. Calculate the total monthly salary of all employees.
12. Print the average annual salary.
13. Select the name, job, salary, department number of all employees except
SALESMAN from department number 30.
14. 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 1600
BLAKE 2850
CLARK 2450
KING 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 800
WARD 1250
JONES 2975
MARTIN 1250
SCOTT 3000
KING 5000
ADAMS 1100
JAMES 950
FORD 3000
MILLER 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 MANAGER
BLAKE MANAGER
CLARK MANAGER
KING 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 MANAGER 2975
BLAKE MANAGER 2850
CLARK MANAGER 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. Display the names of employees with experience of over 10 years or und
0Count the total number of employees.
22. Retrieve the names of departments in ascending order and their employees in
descending order.
23. Find out experience of MILLER.
24. How many different departments are there in the employee table.
25. Find out which employee either work in SALES or RESEARCH department.
26. Print the name and average salary of each department.
27. Select the minimum and maximum salary from employee table.
28. Select the minimum and maximum salaries from each department in employee
table.
29. Select the details of employees whose salary is below 1000 and job is CLERK.
ASSIGNMENT
Batch : 2010-12 Session : 2011-12 Programme: MBA Semester : III/IV
Course Code : 251 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. Create above relations using your own data types and print the structure of the
each relation.
II. 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.
III. Print the contents of the each relation.
IV. Give an expression in SQL with output for each of the following queries:

1. Find the names of all employees who work for First Bank Corporation.
2. Find the names and cities of residence of all employees who work for the First
Bank Corporation.
3. Find the names, street, and cities of residence of all employees who work for
First Bank Corporation and earn more than Rs. 10,000/-.
4. Find the employees who live in the same cities as the companies for which they
work.
5. Find all employees who live in the same cities and on the same streets as do
their managers.
6. Find all employees who do not work for First Bank Corporation.
7. Find all employees who earn more than every employee of Small Bank
Corporation.
8. Find all companies located in every city in which Small Bank Corporation is
located.
9. Find all employees who earn more than the average salary of all employees of their
company.
10. Find the company that has the most employees.
11. Find the company that has the smallest payroll.
12. Find those companies whose employees earn a higher salary, on average, than the
average salary at First Bank Corporation.

You might also like